我用struts做了一个简单应用,为什幺form提交时,Action对象好象不执行?
Action对象会forward到success.html或failuer.html,但是实际执行时没forward到这两个页面。
大家说说大概会因为什么问题造成的?
Register.jsp:
<%@ taglib uri = "/WEB-INF/struts-html.tld" prefix = "html" %>
<html:form action = "jspbook.do">
UserName: <html:text property = "username"/><br>
enter password:<html:password property = "password1"/><br>
re-enter password:<html:password property = "password2" /><br>
<html:submit value = "jsbook" />
</html:form>
web.xml:
<web-app>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld </taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld </taglib-location>
</taglib>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
Action-mapping,action也在struts-config.xml中设定了。
Struts.xml:
<struts-config>
<form-beans>
<form-bean name = "registrationForm" type = "struts.RegistrationForm" />
</form-beans>
<action-mappings type = "org.apache.struts.action.ActionMapping">
<action path = "/jspbook" type = "struts.RegisterAction"
name = "registrationForm" input="/register.jsp">
<forward name = "success" path = "/success.html" />
<forward name = "failure" path = "/failure.html" />
</action>
</action-mappings>
<message-resources parameter="MessageResources" />
</struts-config>