首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

使用struts开发,提交后出错java.lang.ClassCastException

2014-01-26 
提交表单后,浏览器地址栏显示http://localhost:8080/news/NewsDirAdd.dojsessionid8D83E0DF757A2353F7F2F

提交表单后,浏览器地址栏显示http://localhost:8080/news/NewsDirAdd.do;jsessionid=8D83E0DF757A2353F7F2FD809EC74CD6
  页面中报错
  description The server encountered an internal error () that prevented it from fulfilling this request.
 
  exception
 
  java.lang.ClassCastException
  org.apache.struts.tiles.TilesRequestProcessor.initDefinitionsMapping(TilesRequestProcessor.java:84)
  org.apache.struts.tiles.TilesRequestProcessor.init(TilesRequestProcessor.java:75)
  org.apache.struts.action.ActionServlet.getRequestProcessor(ActionServlet.java:602)
  org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
  org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
 
  note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
 
 
  请高人指点!!
  ---------------------------------------------------
 
  〓环境: windows xp
  tomcat-5.0.28
  j2sdk-1_4_1_07
  struts-1.2.7
 
 
  〓struts-config.xml
  ...
  <form-beans>
  <form-bean name="NewsDirAddForm" type="com.utsky.hbcz.form.NewsDirAddForm"/>
  </form-beans>
  ....
  <action-mappings>
  <action path="/NewsDirAdd" type="com.utsky.hbcz.action.NewsDirAddAction" name="NewsDirAddForm" scope="request" input="admin/newsdir/newsdir_add.jsp" />
  </action-mappings>
  ....
 
  〓newsdir_add.jsp
  ...
  <html:form action="/NewsDirAdd" focus="name">
  栏目名称: <html:text property="name" size="16"/>
  <html:submit>保存</html:submit >
  </html:form>
  ....
 
  〓NewsDirAddForm.java
  public final class NewsDirAddAction extends Action {
  public ActionForward execute(ActionMapping mapping,
  ActionForm form, HttpServletRequest request, HttpServletResponse response)
  throws IOException, ServletException {
 
  String name = ((NewsDirAddForm) form).getName();
 
  System.out.print("ok!");
 
  return mapping.findForward("success");
  }
  }

------解决方法--------------------------------------------------------
public final class NewsDirAddAction extends Action {
  public ActionForward execute(ActionMapping mapping,
  ActionForm form, HttpServletRequest request, HttpServletResponse response)
  throws IOException, ServletException {
 
  String name = ((NewsDirAddForm) form).getName();
 
  System.out.print("ok!");         

热点排行