Struts2配置

来源:互联网 发布:女孩子湿有多夸张知乎 编辑:程序博客网 时间:2024/06/06 21:44

1新建dwp项目文件--->structs.xml-->导入jar包(9个必要7个)-->web.xml

2.server Tomcat

解释:Struct.xml 必须放在src下 默认写死了Thread.currentThread().getContextClassLoader().getResource("struts.xml")

或者要想不放在src下自己配置,在web.xml中:<filter> 
<filter-name>struts2</filter-name> 
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
<init-param> 
<param-name>config</param-name> 
<param-value>struts-default.xml,struts-plugin.xml,struts/struts.xml </param-value> 
</init-param> 
</filter>

jar包放在webContent-->webInf-->lib下

web.xml放在webContent-->webInf下

补充:当你改变action的name时要重启服务器才能运行不然报错,解决方案在struct.xml中加一行<constant name="Struts.devMode" Value="true">改成开发者模式可以不需要重启服务

0 0