我正在使用WaveMaker和Springsource MVC的網站上工作。如何使用Spring MVC控制器返回html文件
由WaveMaker生成的條目名爲'index.html'。我將所有瀏覽器端代碼導入到MVC項目的/ view directroy中。並嘗試配置ContextLoadListener將其映射到一個uri。使用:
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String testIndex() {
return "index.html";
}
然後我得到了以下錯誤測試它:
SEVERE: PWC6117: File "C:\glassfish3\glassfish\domains\domain1\eclipseApps\TribblesDashboard\WEB-INF\views\index.html.jsp" not found
如何解決呢?
請參閱http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#mvc-viewresolver。但最簡單的解決方案是將index.html文件重命名爲index.jsp。 –
看起來像你的viewResolver配置不正確。你有沒有定義? – MStodd
默認的viewResolver行爲是自動在末尾使用「.jsp」查找返回的視圖名稱。因此,將「index.html」重命名爲「index.jsp」,然後返回「索引」 – nickdos