我已经开始使用 Spring 框架并且已经遇到了某种愚蠢的问题(但实际上我无法解决它)我的控制器看起来像:
package org.springframework.rest;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class SomeController {
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody
public String returnHtmlPage() {
return "page";
}
}
其中 page 是 page.jsp:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>
Hello world!
</h1>
<P> The time on the server is ${serverTime}. </P>
</body>
</html>
但是我只返回了字符串“page”,而不是 HTML 文件。我该如何解决这个问题?