【发布时间】:2013-03-06 22:19:54
【问题描述】:
我正在使用 Spring 开发一个网站,并尝试提供不是 .jsp 文件(例如 .html)的资源
现在我已经注释掉了我的 servlet 配置的这一部分
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
并尝试从控制器返回资源的完整路径。
@Controller
public class LandingPageController {
protected static Logger logger = Logger.getLogger(LandingPageController.class);
@RequestMapping({"/","/home"})
public String showHomePage(Map<String, Object> model) {
return "/WEB-INF/jsp/index.html";
}
}
index.html 文件存在于该文件夹中。
注意:当我将 index.html 更改为 index.jsp 时,我的服务器现在可以正确地提供页面。
谢谢。
【问题讨论】:
-
我认为 [this answer][1] 可能会有所帮助。 [1]:stackoverflow.com/questions/1483063/…
-
不,这不是我想做的。我希望自己有一个文件夹,就像我用记事本++对网站静态内容进行编程一样。包含我的 index.html 的文件夹,所有内容都相对于该 index.html
标签: java spring spring-mvc