搭了个小demo,工程启动后,点击页面提交按钮,没有任何反应,也没有报错,如下所示:web.xml:<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts-config.xml:
<struts-config>
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/testAction"
type="org.springframework.web.struts.DelegatingActionProxy"
parameter="reqCode"
scope="request">
<forward name="kao"
path="/qwe.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>
applicationContext.xml:
<beans>
<bean name="/testAction" class="test.struts.action.mytest"/>
</beans>jsp:
<form action="testAction.do?reqCode=test" method="post">
<table>
<tr>
<td>
<input type="submit" value="点 它">
</td>
</tr>
</table>
</form>
请指教!!!
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts-config.xml:
<struts-config>
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/testAction"
type="org.springframework.web.struts.DelegatingActionProxy"
parameter="reqCode"
scope="request">
<forward name="kao"
path="/qwe.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>
applicationContext.xml:
<beans>
<bean name="/testAction" class="test.struts.action.mytest"/>
</beans>jsp:
<form action="testAction.do?reqCode=test" method="post">
<table>
<tr>
<td>
<input type="submit" value="点 它">
</td>
</tr>
</table>
</form>
请指教!!!
看看你的mytest怎么写的?
为什么你的类首字母是小写呢?~~~<form action="testAction.do?reqCode=test" method="post">
还有一种可能是你form的action写法 如果是post提交 ?后面的参数可能会忽略的
最好是放在隐藏域在form中
public ActionForward test(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse servletResponse) {
System.out.println("ok");
return mapping.findForward("ko");
}
}
写错了,是大写<bean name="/testAction" class="test.struts.action.Mytest"/> 点击按钮后,url为http://localhost:8080/test/testAction.do?reqCode=test
其它就没有任何反应了,没有输出 ok!
你这样输出ok不是在页面 你看看你控制台有没有
调试js就一段段的alert 早晚能alert出来吧
<form action="testAction.do?reqCode=test" method="post">
<table>
<tr>
<td>
<input type="submit" value="点 它">
</td>
</tr>
</table>
</form> 很久没看过JSP前台代码了,你看看是不是有问题呢 ?
特别是form里面的内容,怀疑请求没有被提交