美文网首页
springboot+thymeleaf开发web,出现 o.s

springboot+thymeleaf开发web,出现 o.s

作者: 未名枯草 | 来源:发表于2018-02-27 10:43 被阅读113次
    ViewController如下所示:
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.GetMapping;
    
    
    @Controller
    public class UserViewController {
    
        @GetMapping("/user/list")
        public String list() {
            return "demo/user_list";
        }
    }
    
    html结构:
    image.png
    thymeleaf配置文件配置:
    #thymeleaf
    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.mode=LEGACYHTML5
    spring.thymeleaf.suffix=.html
    #解决thymeleaf html热启动的问题
    spring.thymeleaf.cache=false
    

    在浏览器中输入一下内容

    http://localhost:8080/user/list
    

    无法找到页面,提示错误如下所示:

    2018-02-26 18:08:15.032 ERROR 10484 
    --- [apr-8080-exec-2] o.s.boot.web.support.ErrorPageFilter    
     : Cannot forward to error page for request [/user/list] 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
    
    解决方案

    1)查看url是否正确
    2)查看maven中引入是否正确:
    发现缺少对应maven引入
    在pom中添加:

          <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
    
            <!--HTML扫描器和标签补偿器-->
            <dependency>
                <groupId>net.sourceforge.nekohtml</groupId>
                <artifactId>nekohtml</artifactId>
                <version>1.9.22</version>
            </dependency>
    

    问题解决;

    相关文章

      网友评论

          本文标题:springboot+thymeleaf开发web,出现 o.s

          本文链接:https://www.haomeiwen.com/subject/fmepxftx.html