使用.do进行跳转,必须在web.xml中添加以下配置servlet-mapping,如下:
在struts-config.xml中的action-mappings添加action配置,如下:
注:我的form-bean配置如下:
jsp页面中的跳转代码如下:
提醒:注意jsp文件应放置于WebRoot中!
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
在struts-config.xml中的action-mappings添加action配置,如下:
<action-mappings>
<action name="testForm" path="/test" scope="request" type="com.action.testAction" validate="true">
<forward name="out" path="/testOut.jsp"/>
</action>
</action-mappings>注:我的form-bean配置如下:
<form-beans>
<form-bean name="testForm" type="com.mycompany.testForm"/>
</form-beans>jsp页面中的跳转代码如下:
<form name="form" method="post" action="test.do?action=out">
<input name="testName" type="text" value="">
<input name="Submit" type="submit" value="Go">
</form>提醒:注意jsp文件应放置于WebRoot中!
Struts框架配置与跳转
本文介绍如何在Struts框架中配置web.xml和struts-config.xml文件来实现.do请求的处理与页面跳转。具体步骤包括在web.xml中设置servlet-mapping,并在struts-config.xml中定义action及forward路径。
406

被折叠的 条评论
为什么被折叠?



