灵魂-放水

为学日益,为道日损。

BlogJava 首页 新随笔 联系 聚合 管理
  296 Posts :: 10 Stories :: 274 Comments :: 0 Trackbacks
今天在用到Struts开发一个应用的时候遇到错误:

exception

javax.servlet.ServletException: Cannot retrieve mapping for action /showProLists
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
	org.apache.jsp.apply.showProList_jsp._jspService(showProList_jsp.java:193)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	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:810)
	org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
	org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
起初,怀疑是:struts-config.xml里的action配置错误,后来仔细检查,发现无错误,排除此疑!
用到的action:
public class ShowProListAction extends Action {
    public ActionForward execute(ActionMapping mapping,
                                 ActionForm actionForm,
                                HttpServletRequest request,
                                 HttpServletResponse Response) {
      // ShowProListForm form = (ShowProListForm)actionForm;
      
       String temp=request.getParameter("testSecID");
       int ID=Integer.parseInt(temp);
       System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+ID);
       ShowProListDAO prolistDAO=new ShowProListDAO();
       ArrayList arr=new ArrayList();
       arr=prolistDAO.getProList(ID);
       if(arr==null){
           return mapping.findForward("null");
       }
       if(arr !=null){
           if(arr.size()==0){
               return mapping.findForward("null");
           }
           else{
               request.setAttribute("showProList",arr);
               request.setAttribute("stationID",temp);
               ArrayList proList=(ArrayList)request.getAttribute("showProList");
               for(int i=0;i<proList.size();i++){
               ShowProList projects=(ShowProList)proList.get(i);
               System.out.println(projects.getProjectName());
               }
               System.out.println(temp);

               return mapping.findForward("success");
           }
       }
return mapping.findForward("fail");
    }
}
System.out.println(temp)和System.out.println(projects.getProjectName());
均正常输出。怀疑,return mapping.findForward("success")怀疑这一步跳转错误?
修改过若干遍struts-config.xml文件,依旧未果!!!!!




最后,dxian来帮忙检查,发现实际上,该action类,完全通过了。是在跳转到下个jsp页面后,jsp页面里有一表单form:
部分代码如下:
<html:form action="showProLists" method="post">showProListAction.do
<br><br>
<%
ArrayList proList=(ArrayList)request.getAttribute("showProList");
%>
因为,刚开始写该jsp页面时,是copy了一个过来直接改的,忘记把里的form去掉!结果,发生了错误!
至此,该问题解决!先前都没遇到过这个情况,花了好多时间在这个上面。
末了,要感谢下帮过我无数次的 dxian:)
posted on 2006-07-16 18:39 放水老倌 阅读(4490) 评论(1)  编辑  收藏 所属分类: Struts

Feedback

# re: javax.servlet.ServletException: Cannot retrieve mapping for action /showProLists 2007-12-10 12:02 wangming1248
<html:form action="showProLists" method="post">showProListAction.do<br><br>

应该改成
<html:form action="/showProLists" method="post">showProListAction.do<br><br>  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: