【发布时间】:2018-11-14 09:35:00
【问题描述】:
我将 Spring Boot 应用程序设置为 REST api。我现在还希望能够为客户端提供简单的 HTML 页面,而无需在任何模板引擎(如 Thymeleaf)上使用。我希望通过使用 WebSecurityConfigurerAdapter 来访问 HTML 页面,使其受到 Spring Security 设置的相同安全约束,该约束已经存在于我的应用程序中。
我尝试过的是Controller:
@Controller
public class HtmlPageController {
@RequestMapping(value = "/some/path/test", method = RequestMethod.GET)
public String getTestPage() {
return "test.html";
}
}
并将test.html 文件放入/resources/test.html 或/webapp/WEB-INF/test.html。
每次我尝试访问localhost:8080/some/path/test 的页面时,都会返回404。
我该如何进行这项工作?
【问题讨论】:
-
试试
return "test"; -
如果我这样做,服务器会抛出
Circular view path [test]: would dispatch back to the current handler URL [/some/path/test] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
标签: java spring spring-mvc spring-boot