我试图在谷歌应用引擎上构建一个spring mvc网页。但我无法进行路由/映射工作。谷歌应用引擎中的Spring MVC路由
我有我的HelloController
,这表明我希望映射到/hello
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String Index() {
return "hello";
}
}
和一个非常简单的hello.jsp
文件
<html>
<head><title>Hello :: Spring Application</title></head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings.</p>
</body>
</html>
然而,当我尝试访问/hello
,我会得到404找不到。
这里是我的XML映射文件mvc-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.example.web" />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
我缺少什么?如何解决它?
你在web.xml中映射的servlet春天? – 2015-03-03 07:43:10
你把hello.jsp放在哪里?我想你应该把它放在'InternalResourceViewResolver'配置中'prefix'指定的目录中 – hsluo 2015-03-03 09:41:06