現在、自分の勉強のためにJava、spring bootをメインに自分で開発を行おうとしている初心者です。
実現したいこと
src/main/resource/templates/management/list/index.htmlに遷移したいですがなぜ飛べないのかわかりません。
ログインボタンを押下して画面を遷移させたいのですが
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Not Found, status=404).
と表示されうまくいきません。
発生している問題のソース
LoginController
@ResponseBody @RequestMapping(value = "/login", method = RequestMethod.POST) public Response index(@RequestPart("json") LoginUser loginUser,Model model) { log.info("こここここここここここここ"); Response resp = null; resp = Response.status(Status.OK).entity("/management/list").build(); return resp; }
index.js
//ログインボタン押下時 $('#loginBtn').click(function(){ var errMsg = ''; if($('#user').val() == '' ){ errMsg = '「ID」'; } if($('#pass').val() == '' ){ errMsg += '「パスワード」' } if( errMsg == '' ){ formPost(); }else{ window.alert( errMsg + 'が未入力です。' ); } }) //入力値に異常がない場合 var formPost = function() { //API var fd = new FormData(); var obj = { "login_id" : $('#user').val(), "password" : $('#pass').val(), }; fd.append("json", new Blob([JSON.stringify(obj)], { type: "application/json" })); $.ajax({ url: '/login/', type: 'post', dataType: 'json', data: fd, processData: false, contentType: false }).done(function(res) { if (res.status == '200') { console.log('SUCCESS', res); window.location.href = "/management/list"; }
遷移させたいindex.html
<!DOCTYPE html> <html lang="ja" xmlns:th="http://www.thymeleaf.org" > <head> <meta charset="utf-8"> <title>Management</title> <link rel="stylesheet" href="../../../static/management/list/css/index.css" th:href="@{/management/list/css/index.css}" > <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> </head> <body> hogehoge <script src="../../../static/management/list/js/index.js" th:src="@{/management/list/js/index.js}"></script> </body> </html>
試したこと
window.location.href = 外部のURL
遷移確認済み。
window.location.href = "/login";
src/main/resource/templates/login/index.html に遷移確認済み。
補足情報
Eclipse
Google Chrome
JavaSE11
どなたか教えてください・・・
よろしくおねがいします
あなたの回答
tips
プレビュー