我正在尝试使用带有spring MVC的表单按钮。单击表单按钮后,它将转到另一个页面(showData.jsp)。不幸的是,当我点击按钮时没有任何反应。我将在下面提供我的代码并感谢您的帮助。
带有表单代码的JSP文件:
<form:form method="POST" action="${pageContext.request.contextPath}/showPage">
<button type="button" value="button" name="button"> Click Here!</button>
</form:form>
控制器代码:
@RequestMapping(value = "/showPage", method = RequestMethod.POST)
public String printWelcome() {
return "showData";
}
分配器一小服务程序
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.springapp.mvc"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
答案 0 :(得分:0)
尝试使用输入标记而不是按钮标记:
<form:form method="POST" action="${pageContext.request.contextPath}/showPage">
<input type="submit" value="Click here!" name="button" />
</form:form>