Posted on 2006-04-07 20:56
gong 阅读(3530)
评论(2) 编辑 收藏 所属分类:
struts
struts 中如果配置多个module, 可能有问题, 我调试了struts源码发现确实是问题,
有待于网友们进一步确认.我使用的是struts1.1, 配置了两个module: 缺省: struts-config.xml ,
admin: struts-config-admin.xml
category.jsp
--------------------------------
<frameset rows="*" cols="180,*" frameborder="yes" framespacing="1px" border="0" >
<frame name="menuFrame"
src="../categoryAction.jspx?method=loadAllMenus" scrolling="No"
noresize="noresize" >
<frame name="deatilFrame" src="categoryDetail.jsp" >
----------------------------------
categoryDetail.jsp
----------------------------------
<html:form action="categoryAction.jspx?method=saveCategory" >
... ...
<html:form>
-----------------------------------
struts-config-admin.xml:
------------------------------------
<action
attribute="categoryForm"
input="/product/categoryDetail.jsp"
name="categoryForm"
parameter="method"
path="/categoryAction"
scope="request"
validate="false"
type="com.book.web.struts.action.CategoryAction" >
<forward name="viewMenu" path="/product/categoryMenu.jsp" />
<forward name="succ" path="/product/categoryDetail.jsp" />
</action>
-----------------------------------
以链接的形式访问正确, 直接访问action
http://localhost:8080/promtion/admin/categoryAction.jspx?method=saveCategory
正确.
但把action 放到jsp页面中就出错, http://localhost:8080/promtion/admin/category.jsp
javax.servlet.ServletException: Cannot retrieve mapping for action /categoryAction
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.admin.product.categoryDetail_jsp._jspService(categoryDetail_jsp.java:101)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /categoryAction
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:810)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.admin.product.categoryDetail_jsp._jspx_meth_html_form_0(categoryDetail_jsp.java:187)
org.apache.jsp.admin.product.categoryDetail_jsp._jspx_meth_html_html_0(categoryDetail_jsp.java:147)
org.apache.jsp.admin.product.categoryDetail_jsp._jspService(categoryDetail_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
我调试了struts 源码发现 刚开始 也能取到module 的name 值为admin, 但在后续处理的时候就把该值丢了,
于是struts只能从struts-config.xml 文件读取,
而不是从struts-config-admin.xml中读取action, 所有就找不到了action, 抛出异常.
struts 1.2 我还有待测试, 不知道是否有同样的问题.?
其它相同问题的网友发言:
原文链接1:http://www.blogjava.net/shaofan/archive/2006/03/01/32974.html
原文链接2:http://202.100.72.44/news/itschool/pro/pro44134.htm