关于运用Spring的mvc进行程序开发所遇到的不能跳转的问题。
小弟在jsp中代码如下:
<%@page contentType="text/html;charset=GBK"%>
<html>
<head><title>Test again</title></head>
<body>
<form name="query" action="Query.do" method="post">
Query<br>
<input type="submit" name="method" value="query"/><br>
<input type="submit" name="method" value="insert"/>
</form>
</body>
</html>
web.xml代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--初始化参数-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mapping.xml,/WEB-INF/spring-datasource.xml</param-value> </init-param>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</servlet>
</web-app>
spring-mappings.xml代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--定义映射-->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="Query.do">Query</prop>
</props>
</property>
</bean>
<!--定义视图-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.InternalResourceView</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!--定义控制器-->
<bean id="Query" class="com.gc.action.QueryAction">
<property name="methodNameResolver">
<ref bean="paraMethodResolver"/>
</property>
<property name="viewPage">
<value>Query</value>