`
weir2009
  • 浏览: 264016 次
  • 性别: Icon_minigender_1
  • 来自: 惠州
社区版块
存档分类
最新评论

Struts的action问题

阅读更多
配置文件:struts.xml

XML code

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <constant name="struts.custom.i18n.resources" value="q2c"/> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.objectFactory" value="spring" /> <constant name="struts.devMode" value="true" /> <constant name="struts.server.static.browserCache" value="false"/> <constant name="struts.configuration.xml.reload" value="true" /> <constant name="struts.ui.theme" value="simple" /> 省略… <include file="com/qtoc/config/item/item.xml"></include> </struts>


item.xml文件

XML code

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> 省略… <package name="item" namespace="/item" extends="qtoc"> <action name="spStyleManageUI*" class="com.qtoc.item.action.style.SpStyleManageAction" method="{1}"> <result>/WEB-INF/base/item/{1}_style.jsp</result> </action> </package> </struts>


在页面上有XXX.Jsp:
<s:url action="spStyleManageUIaddUI" namespace="/item"/>
如果是把item.xml包含在Struts.xml中,当启动tomcat解析XXX.jsp时
<s:url action="spStyleManageUIaddUI" namespace="/item"/>
会被解析成:/item/spStyleManageUIaddUI;jsessionid=37289372937293872893273

如果把:
<action name="spStyleManageUI*" class="com.qtoc.item.action.style.SpStyleManageAction"
method="{1}">
<result>/WEB-INF/base/item/{1}_style.jsp</result>
</action>
直接写在Struts.xml里面,解析出来就是:
/item/spStyleManageUIaddUI
现在还不知道是什么原因,发现后就贴上来了,希望同网友分享,解决原因。
struts2是最新的2.1.8.1
我又测试了一下,跟namespace="/item"没关系,就是<include file="com/qtoc/config/item/item.xml"></include>
包含的问题,但还没测试是不是版本问题。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics