struts.xml里的常用配置也可配置到struts.properties

<!-- 国际化编码 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- 主题 -->
<constant name="struts.ui.theme" value="simple"/>
<!-- 定位视图资源的根路径。默认值为/WEB-INF/content -->
<constant name="struts.convention.result.path" value="/WEB-INF/template" />

从name属性值的struts.convention.result.path不难发现,不用在struts.xml中配置Action的相关属性了,只要在Action对应方法的return值那写上对应跳转到/WEB-INF/template/xxx.jsp。   

例如:http://localhost:8080/freemarker-test/test!findInfo.action   在findInfo方法 renturn "stuInfo";  此时视图就会定位在/WEB-INF/template/stuInfo.jsp

前提是:配置了下面的<constant value="MAIN" name="struts.convention.default.parent.package" />(默认父包),并且在对应Action类上添加@ParentPackage("MAIN")注解,这是在告诉struts拿到return过来的字符串之后根据设定的视图资源路径找到对应的视图文件。

<!-- 后缀 -->
<constant name="struts.action.extension" value="action"/>
<!-- 是否将actionName分割,去掉action部分,以大写字母作为分割 -->
<constant name="struts.convention.action.name.separator" value="_" />
<!-- 浏览器是否缓存静态内容 ,开发阶段最好关闭-->
<constant name="struts.serve.static.browserCache" value="false"/>
<!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 --> 
<constant name="struts.configuration.xml.reload" value="true"/> 
<!-- 配置使用Spring管理Action -->
<constant name="struts.objectFactory" value="spring"/>
<!-- 设置默认的父包 -->
<constant value="MAIN" name="struts.convention.default.parent.package" />

<package name="MAIN" extends="struts-default" namespace="/">
</package>

注:以上配置信息是在网上down下来的然后自己做了测试,在此感谢提供配置信息的大神!

原文地址:https://www.cnblogs.com/xmaomao/p/2984802.html