Spring MVC
框架中的第一个Imma noobie ......
我在 Intellij Idea 中创建了一个项目并且它可以正常工作,但是我无法知道如何找到我的 index.jsp 的默认控制器。在控制器代码(com.contedevel.lab01.IndexController
)下面:
@Controller
@RequestMapping({"/", "/index"})
public class IndexController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "index";
}
}
我的观点( /index.jsp ):
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>ConteDevel</title>
</head>
<body>
${message}
</body>
</html>
/WEB_INF/dispatcher-servlet.xml :
<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.contedevel.lab01"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
在浏览器中,我看到的是${message}
而不是"Hello Spring MVC Framework!"
,但我需要从控制器中看到 time site
1 1/01/2000 A
2 1/02/2000 A
3 1/03/2000 A
4 1/04/2000 A
5 1/05/2000 A
6 1/06/2000 A
7 1/07/2000 A
8 1/08/2000 A
9 1/09/2000 A
10 1/10/2000 A
11 1/11/2000 A
12 1/12/2000 A
13 1/01/2001 A
14 1/02/2001 A
15 1/03/2001 A
16 1/04/2001 A
17 1/05/2001 A
18 1/06/2001 A
19 1/07/2001 A
20 1/08/2001 A
21 1/09/2001 A
22 1/10/2001 A
。
什么可能是错的?