我正在设置和“ / home”映射的Rest Endpoint。如何返回网页(.HTML)。
我尝试了响应重定向,但是似乎没有选择要重定向的文件。
@RequestMapping("/home")
public ReturnType welcome() {
return "First\src\main\resources\static\home.html";
}
NOTE : ReturnType here is mentioned ,as unbale to decide on return type
我需要返回放置在(First \ src \ main \ resources \ static \ home.html)处的home.html作为请求映射“ / home”的响应
答案 0 :(得分:0)
最好是直接流式传输内容。
@RequestMapping("/home")
public InputStreamResource welcome(ServletResponse output) {
intput=this.getClass().getResourceAsStream("static\home.html");
return new InputStreamResource(inputStream);
}
如果禁用了内容嗅探,则可能需要设置一些响应标头。