jsp页面用了几个struts标签
<html:form action="/register">
<html:text property="username"/><br>
<input type="submit" value="register" ><br>
</html:form>
struts-config.xml
<struts-config>
<form-beans>
<form-bean name="registerForm" type="org.apche.struts.action.DynaActionForm">
<form-property name="username" type="java.lang.String"/>
</form-bean>
</form-beans>
<action-mappings>
<action path="/register" type="struts.RegisterAction"
name="registerForm" input="/test/register.jsp" >
<forward name="success" path="/success.jsp">
</forward>
<forward name="fail" path="/fail.jsp">
</forward>
</action>
</action-mappings>
</struts-config>
然后访问jsp页面的时候报异常
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception creating bean of class org.apche.struts.action.DynaActionForm: {1}
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
控制台里空指针异常
严重: Error creating form bean of class org.apche.struts.action.DynaActionForm
java.lang.NullPointerException
at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:254)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:208)
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:505)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:482)
at org.apache.jsp.test.register_jsp._jspx_meth_html_005fform_005f0(register_jsp.java:97)
at org.apache.jsp.test.register_jsp._jspService(register_jsp.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
用的struts1.38,用普通的ActionForm正常
------解决方案--------------------