In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what the solution to the problem that springboot cannot jump to the page is. The content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
First of all, my login page requests direct access through the browser, and the project structure is shown in the figure.
Login page
$(function () {)
$("# but") .click (function () {
Var data = $("# frm") .serialize ()
Get ("index", data);
})
})
After clicking submit, an ajax sends the data in the form with the request address of index. It will go to the database to query whether this person exists (the backend uses mybatis to query the database), and jump to the corresponding page according to the returned result. The java code of the index request I wrote in controller is:
/ log in to @ GetMapping ("index") public String addDept (Dept dept) {log.info ("dept===" + dept); List depts = deptService.selectDept (dept); if (depts! = null) {return "index";} else {return "error";}}
Something unexpected happened, and the query result came out, and it also entered the if judgment, but it did not jump to the page. This question was confused for a long time, but I never thought of where the problem occurred. Baidu had a lot of results, including the following results given by Baidu:
Annotations use @ Controller instead of @ RestController, because @ RestController returns the "index" string. First introduce the template engine jar package into the pom file, that is:
Org.springframework.boot
Spring-boot-starter-thymeleaf
Configure the template engine in application.properties
Spring.thymeleaf.prefix=classpath:/templates/
Do not add the @ responseBody annotation, because it will return the form of a string. I have tried all the above pits, but I have not failed in the end, but if I enter the index request directly into the browser, I will jump to the index.html page. I wonder, but I still don't know what my problem is.
The page of my index.html is as follows. Use the ajax request and call the request to query everyone in the database. The code is as follows:
Index page
SelectDept () function selectDept () {
Get ("getDept", callSelectDept, "JSON") function callSelectDept (data) {
Var str= "" for (var I = 0bot I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.