为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Boot 无法解析 Thymeleaf 视图

Spring Boot 无法解析 Thymeleaf 视图

拉丁的传说 2021-06-30 14:15:14
我将 Spring Boot 与 Thymeleaf 集成在一起,但在控制器返回视图后,Web 不会重定向或转发。这是 Thymeleaf 页面:<!DOCTYPE html><html xmlns:th="http://www.thymeleaf.org"><head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1">    <title>login</title>    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.css}" rel="stylesheet">    <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans:400,300'>    <link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>    <link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}"></head><body>            <div class="cont_forms">                <div class="cont_img_back_">                    <img src="https://images.unsplash.com/42/U7Fc1sy5SCUDIu4tlJY3_NY_by_PhilippHenzler_philmotion.de.jpg?ixlib=rb-0.3.5&q=50&fm=jpg&crop=entropy&s=7686972873678f32efaf2cd79671673d"                         alt=""/>                </div>                <div class="cont_form_login">                    <a href="#" onclick="ocultar_login_sign_up()"><i class="material-icons">&#xE5C4;</i></a>                    <h3>login</h3>                    <input id="login_name" type="text" placeholder="username"/>                    <input id="login_password" type="password" placeholder="password"/>                    <div class="checkbox mb-3" style="margin:5% auto 0% 2%">                        <label>                            <input type="checkbox" id="remember"> Remember me                        </label>                    </div>                    <p style="color: red" th:text="${msg}" th:if="${not #strings.isEmpty(msg)}"></p>                    <button class="btn_login" onclick="login('http://localhost:8080/assignment/user/login')">login</button>                </div>            </div>        </div>    </div></div>
查看完整描述

1 回答

?
动漫人物

TA贡献1815条经验 获得超10个赞

要渲染视图,您需要使用@Controller.


改变这个:


@RestController

public class LoginController {

}

至:


@Controller

public class LoginController {

}


查看完整回答
反对 回复 2021-07-14
  • 1 回答
  • 0 关注
  • 337 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号