我正在尝试使用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>
2条答案
按热度按时间nbysray51#
尝试使用input标签而不是button标签:
bgibtngc2#
你的按钮可能看起来像这样:
你的Map可以是这样的: