我尝试了SPRING MVC项目。
我的文件结构像 my file and dispatcher-servlet.xml is below
我的web.xml是
<web-app>
<display-name>springmvc</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
</web-app>
我的HelloController在下面:
package com.tcbbank.controller;
@Controller
public class HelloController {
@RequestMapping(value = "/hello.jsp", method = RequestMethod.GET)
public String getValue() {
return "hello";
}
}
我的hello.jsp就像
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>Hello</h2>
</body>
</html>
当我尝试http://localhost:8580/springmvc/hello.jsp时,浏览器 返回404。 任何人的建议都非常感谢。