Loading...

java .net

开始学习struts2(七)

好久没写了,过了个年,过了七天猪的日子,吃了睡睡了吃中间偶尔看看电视,为假期准备了几个电影都没看,唉:-(忙,上了几天班了,怎么感觉这周过的这么慢呢,刚刚刚周四
昨儿看了一集struts2

总结几点

1、struts.xml中的package标签有个abstract="true"属性,如果为true,则这个package中不能有<action>标签,为true表示这个package为一个抽象package,就像java中的接口中不能有方法实现似的。

2、package标签还有个namespace属性,它关系到这个package中的action访问路径,默认是"",比如

<package name= "capinfo" extends= "struts-default" namespace="/hello">
<action name= "HelloWorld"
class= "com.capinfo.struts2.action.HelloWordAction" >
<result>/HelloWorld.jsp</result>
</action>
</package>

则jsp中则应为<form action="/hello/HelloWorld.action" method="post">,如果没有找到hello/HelloWorld.action则会寻找namespace为""的,也就是HelloWorld.action,如果再没有,就会抛出异常。

3、在struts1中可以有多个struts-config.xml的文件,只要在web.xml配置org.apache.struts.action.ActionServlet时加到config参数中,以逗号分隔,在struts2中也可以有多个struts.xml形式的文件,这次不需要修改web.xml了,在struts.xml中添加诸如
<include file=""/>就Ok了

4、关于struts各种参数的配置信息位于struts2-core.jar/org.apache.struts2/default.properties中,如果要修改里面的配置,有两种方式,一是在struts.xml中配置,例如<constant name="struts.devMode" value="true" />,二是在classess中建一个struts.properties,在里面配置比如struts.i18n.encoding=GBK,在struts2-core.jar/org.apache.struts2/default.properties中有一下这句注释,说明了struts.properties将覆盖default.properties中的配置

### Struts default properties
###(can be overridden by a struts.properties file in the root of the classpath)
###

就总结这么些先。

posted on 2009-02-05 13:40 阅读(309) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

公告

希望有一天

我能用鼠标双击我的钱包

然后选中一张100元

按住“ctrl+c”

接着不停的“ctrl+v”

嘻嘻~~~笑醒~~~



导航

<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

统计

常用链接

留言簿(6)

随笔分类(102)

随笔档案(398)

文章分类

文章档案(10)

有趣网络

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜