1.某项目分模块的web.xml配置如下:
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/rights</param-name>
<param-value>/WEB-INF/rights-struts-config.xml</param-value>
</init-param>
2.rights-struts-config.xml中某action的配置如下:
<action
path="/rights/listrights"
parameter="browseRight"
scope="request"
>
<forward name="rightbrowse" path="/rights/rightbrowse.jsp"/>
<forward name="rightbrforupd" path="/rights/rightbrforupd.jsp" />
<forward name="rightbrfordel" path="/rights/rightbrfordel.jsp" />
</action>
3.请求路径如下:
http://localhost:8080/netctoss_my/rights/listrights.do?type=1
出现错误如下:
2009-07-08 11:53:31,906 ERROR [org.apache.struts.action.RequestProcessor] - Invalid path was requested /listrights
当action的path改为 path="/listrights",则出现如下错误:
HTTP Status 404 -
/rights/rights/rightbrowse.jsp
type Status report
message /rights/rights/rightbrowse.jsp
description The requested resource (/rights/rights/rightbrowse.jsp) is not available.
再把Forward中path属性前面的/rights 去掉,则页面跳转正确。
4.页面表单Form的请求:
相对路径:action="listrights.do" 没有right开头,直接现对http://localhost:8080/netctoss_my/rights/index.jsp中的right模块
绝对路径:action="action="<%=request.getContextPath()%>/rights/listrights.do""
<form name="rightCondForm" method="post" action="listrights.do">
查询条件:
模块名称:<input type="text" name="moduleName" value="" style="WIDTH:100px">
权限名称:<input type="text" name="operationName" maxlength="20" value="" style="WIDTH: 100px">
<input type="hidden" name="type" value="1"/>
<input type="submit" value=" 查询">
</form>
总结:Struts1.2在分模块的配置文件中,根据web.xml的配置:
<init-param>
<param-name>config/rights</param-name>
<param-value>/WEB-INF/rights-struts-config.xml</param-value>
</init-param>
前面默认加上了rights。所以在rights-struts-config.xml的配置中,action的path属性不用加上/rights了。
但是,如果整合了Spring,需要对action注入业务service,则spring的资源文件配置如下:
<!-- web start -->
<bean name="/rights/listrights" class="com.tarena.oss.web.actions.RightRoleAction">
<property name="rightService">
<ref bean="rightServiceProxyBean"/>
</property>
</bean>
<!-- web end -->
name="/rights/listrights,不管Spring是否分了模块,这都要加上/rights模块名
Struts1.2分模块后的路径问题
猜你喜欢
转载自liss.iteye.com/blog/1054511
今日推荐
周排行