首页 技术 正文
技术 2022年11月12日
0 收藏 724 点赞 3,352 浏览 1685 个字
     <package name="mypackage" extends="struts-default">
<global-results>
<result name="error">/success.jsp</result>
</global-results>

其它包 extends=”mypackage” 就可以用到它里面的参数了

常量

     <constant name="struts.devMode" value="true"></constant>
<constant name="struts.i18n.encoding" value="UTF-8"></constant><!-- 相当于HttpServletRequest.setCharacterEncoding("UTF-8") -->
<constant name="struts.action.extension" value="action,,do"></constant><!-- Struts2框架实际要处理的后缀 -->
<constant name="struts.serve.static.browserCache" value="false"></constant><!-- 静态资源是否需要缓存,开发阶段最好改成false -->
<constant name="struts.enable.DynamicMethodInvocation" value="false"></constant><!--禁用动态方法调用 -->
<constant name="struts.multipart.maxSize" value="52428800"></constant>      <!-- 限制文件大小-->

struts2中每个请求都局部创建一个变量执行的,所以是线程安全的

<include file=””></include>导入其他文件的 配置,为了解决action配置太多 看的花

struts.xml中关闭动态调用 ,!后面就是动态调用

//(不建议使用)动态方法调用:http://localhost:8080/struts2day02/customer/addCustomer!updateCustomer(应该执行addCustomer,使用!updateCustomer,在请求addCustomer就执行了updateCustomer)
//关闭动态调用的功能:struts.enable.DynamicMethodInvocation = false

<constant name=”struts.enable.DynamicMethodInvocation” value=”false”></constant>

{1}代表前面的*

         <action name="orders_*" class="cn.itcast.action.OrdersAction" method="{1}">
<result type="dispatcher" name="success">/orders/{1}.jsp</result>
<result type="dispatcher" name="input">/orders/{1}.jsp</result>
</action>
<!--
当访问http://localhost:8080/struts2day02/orders/orders_add动作时,就去调用add方法,并且转向add.jsp页面。因为使用了通配符。
-->

struts 会根据 变量是否存在,如果不存在会创建一个实例变量 并且赋值。例如

public class Customer

{

  String id;

Address  a;

set()get()省略

}

框架会new出 Address并且赋值

jsp中 <input type=”radio” name=”hobby” value=”吃饭”>

jsp中 <input type=”radio” name=”hobby” value=”睡觉”>

类设计中class

String[]hobby;

ActionContext.getContext() 可以用于获取Action上下文

上一篇: IOS后台文件上传
下一篇: unity3d创建window
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,992
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,506
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,767
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844