【发布时间】:2015-03-16 22:57:59
【问题描述】:
我正在使用 Eclipse、Spring MVC、Maven 和 Tomcat。此index.jsp 在 Web 浏览器中显示如下所示。渲染不正确。
知道有什么问题吗?
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Index</h1>
</body>
</html>
@Controller
public class HelloController {
@RequestMapping("/greeting")
public String sayHello() {
System.out.println("Greeting");
return "hello";
}
@RequestMapping("/")
public String index() {
System.out.println("Index page");
return "index";
}
}
【问题讨论】:
-
它正在输出
<%@page...等? -
是的,它正在输出
-
您是如何创建 JSP 文件的?它在您的项目中的什么位置?您如何访问它(您使用的是什么 URL)?
-
我使用 Eclipse 菜单创建它,并将其放置在 WebContent/WEB-INF/jsp/ 中,我在运行时使用 / 访问它
-
你是如何访问它的?