Comment puis-je servir html statique de printemps de démarrage?

J'ai couru le spring-boot-échantillon-web-static projet de ici, fait de cette modification de la pom

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

Et ajouté cette classe pour servir une double page index2.html de la même static emplacement de dossier:

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";
    }
}

Le json url fonctionne bien, mais quand j'essaie d'accéder à localhost:8080/tw j'obtiens une page blanche, et cette erreur dans la console:

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

Je fais quelque chose de mal?

vous n'avez pas vraiment besoin de tomcat dépendance, printemps starter web & thymeleaf devrait le faire.

OriginalL'auteur osmingo | 2017-02-22