spring boot 添加html,如何从Spring Boot提供静态HTML?

我从这里运行spring-

boot-sample-web-static项目,对pom进行了更改

org.springframework.boot

spring-boot-starter-tomcat

并添加了此类,以从相同的static文件夹位置提供重复的页面index2.html :

import org.springframework.http.MediaType;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

@Controller

public class Rester {

@RequestMapping(value = "/rand", produces = MediaType.APPLICATION_JSON_VALUE)

@ResponseBody

private RandomObj jsonEndpoint() {

return new RandomObj();

}

@RequestMapping(value = "/tw")

public String somePg() {

return "index2";

}

}

json url工作正常,但是当我尝试访问localhost:8080 / tw时,我得到了一个空白页,并且在控制台中出现此错误:

2017-02-22 15:37:22.076 ERROR 21494 --- [nio-8080-exec-9] o.s.boot.web.support.ErrorPageFilter : Cannot forward to error page for request [/tw] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

难道我做错了什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值