我使用Spring框架已经开始和我已经跨越了某种愚蠢的问题来到(但其实我也解决不了的话)我有控制器,它看起来像:REST Web服务
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.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>
但保证HTML文件我只有字符串“页面”返回。我该如何解决这个问题?
删除'@ ResponseBody' :)那么你是在创建一个REST服务还是一个Web App? –
我不敢相信!差不多花了1.5小时!谢谢鲍里斯!关于问题,现在我正在发现Spring框架,在此之后,我将尝试创建REST服务 – Mithrand1r