我只是想創建一個簡單的彈簧web應用程序。當我嘗試導航到http://localhost:8080/spring-test/VIEW/VIEW I receive 404 error :
沒有找到彈簧控制器內的請求映射
HTTP Status 404 - /spring-test/VIEW/VIEW
type Status report
message /spring-test/VIEW/VIEW
description The requested resource (/spring-test/VIEW/VIEW) is not available.
我的下面的配置是否正確?
TestController.java:
package com;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("VIEW")
public class TestController {
@RequestMapping("VIEW")
public String showView(final ModelMap argMap) {
return "test.jsp";
}
}
的applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="myController" class="com.TestController">
</bean>
<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="order" value="0" />
<property name="portletModeMap">
<map>
<entry key="view" value-ref="myController" />
</map>
</property>
</bean>
</beans>
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5">
<display-name>Spring3MVC</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/*.xml</param-value>
</context-param>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
項目佈局:
嘗試更改<輸入鍵= 「查看」,以<輸入鍵=「查看」 – Satya
@Satya我嘗試過,結果相同 –