The main contents of this chapter:
With previous learning, we learned and quickly completed the first spring boot application. Spring Boot Enterprise Framework, then how does spring boot read static resources? such as JS folder, CSS files and png/jpg pictures? How do I customize a message converter? How do I customize the configuration of spring MVC? These are all we need in the company. How do we solve this? This is explained in detail in the next section. Okay, now open Spring Boot's web Development Section Fifth
This article is "Edith accompany you learn series-Framework learning Spring Boot Framework Learning" in the Nineth Spring Boot framework Learning 9-spring Boot Web Development (5)-Error resolution and jump page
This article is published by Edith Java (Public number: Kaigejava) on the personal blog site.
Disclaimer: This article is Edith Java (www.kaigejava.com) original, without permission, no reprint!
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 6d8e352dea340928736bd36bffdc9f44x474x270x12.jpeg "alt=" 6d8e352dea340928736bd36bffdc9f44x474x270 "/>
The main contents of this section:
1: Error resolution. Browser access path tip 404 error page
2: Jump to the pre-logon page after logging in
One: Browser access path hint 404 error page
In the Spring boot framework Learning 6-spring Boot Web Development (2), we have set the prefix and suffix of the return page. Such as:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 900771fbd42b0892ff305fabd60a631fx485x58x2.png "alt=" 900771fbd42b0892ff305fabd60a631fx485x58x "/>
But when the browser access is still 404 error page, how to do?
After querying, we find that we need to add the following dependencies:
Add in Pom.xml:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ Aa561a359ee72b053522535dbe0bd911x679x388x9.png "alt=" aa561a359ee72b053522535dbe0bd911x679x388 "/>
<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.6.1</version> <scope>provided</scope> </dependency> |
After restarting the service, revisit:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 9a997d82fc97982c5bf1590667acdbc8x481x103x3.png "alt=" 9a997d82fc97982c5bf1590667acdbc8x481x103 "/>650) this.width=650, "src=" Http://kaigejava.com/res/plugins/ueditor/themes/default/images/spacer.gif "alt=" spacer.gif "/>
Second: Log in and jump to the pre-logon page
Requirement: When the user accesses the hijsp page, if no login jumps to the login page, when the login is completed, jump to the hijsp page to visit.
Analysis:
Determine if the user is not logged in, go to login. What does this feature do?
In the Spring Boot Framework Learning 8-"dry" Spring Boot Web Development (4)-Custom interceptor article we learned to handle with custom interceptors. Then we will then modify the custom class, such as:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ Dff952ee0dc744715df338b774e7b78bx1258x704x27.png "alt=" dff952ee0dc744715df338b774e7b78bx1258x70 "/> Description:
The area in 1 is:
When access is the path is/dologin, login, JS, CSS, GIF or JPG, etc.
The area in 2 is:
When the user information is not obtained from the session, the login page of the jump
The area in 3 is:
If the user is logged in, the execution proceeds directly.
The Dologin method is as follows:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 53a906b18e4073aec300ce79f084d340x1246x631x25.png "alt=" 53a906b18e4073aec300ce79f084d340x1246x63 "/>
Description
The 1 indicates:
When the user name, password exists, from the session to get the user really need to go to the page, and then through the redirect to the corresponding page
The 2 indicates:
The login page that jumps directly when the user is not logged in.
To run the project:
The direct access hijsp path is not logged in and is redirected to the login page. Such as:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 8da7a7c9019dff05684fdfff8c03291bx457x167x6.png "alt=" 8da7a7c9019dff05684fdfff8c03291bx457x167 "/>
Enter your username and password, and click Login to return to the hijsp page you want to go to. For example:
650) this.width=650; "Src=" http://image.uc.cn//s/wemedia/s/upload/2017/ 43ba12cb336be385bf0c34c17e54553cx340x142x5.png "alt=" 43ba12cb336be385bf0c34c17e54553cx340x142 "/>
At this point, we completed the use of spring boot can not directly access the JSP page bug, but also completed, click Login, jump to the user before the page visited.
Next Chapter Trailer:
In the next section, we will explain data persistence. Mainly from the following aspects of the explanation:
MyBatis and Spring boot integration, Redis (standalone) and spring boot integration, Redis (cluster) and spring boot integration, httpclient and spring boot integration, RABBITMQ, and spring Boot integration.
You are welcome to continue your study. We also welcome your valuable suggestions.
Spring Boot Related tutorials:
Spring Boot Framework Learn the important annotations of preschool mastery (1)-spring Java configuration method
Spring Boot Framework Learn important annotations for preschool Mastery (2)-Configure with Java configuration spring
Spring Boot Framework Learn important notes for preschool mastery (3)-read external resource profiles by annotation
Spring Boot Framework Learn important notes for preschool mastery (4)-read external resource profiles by annotation 2
Spring Boot Framework Learning 1-Understanding Spring boot and QuickStart
Spring Boot Framework Learning 2-spring boot core (1)
Spring Boot Framework Learning 3-spring boot core (2)
Spring Boot Framework Learning 5-spring Boot Web development (1)
Spring Boot Framework Learning 6-spring Boot Web Development (2)
Pring Boot Framework Learning 7-spring Boot Web Development (3)-Custom message converters |
Welcome to the Gothic public: Edith Java
Welcome to visit Edith Personal website: www.kaigejava.com
The source of this article: HTTP://WWW.KAIGEJAVA.COM/ARTICLE/DETAIL/62
Spring Boot Series Tutorial Address: http://kaigejava.com/article/list?cateid=3
Spring Boot related ebooks: Spring boot related ebooks
This article from the "Edith Java" blog, reproduced please contact the author!
Spring Boot Framework Learning 9-spring Boot Web Development (5)-Error resolution and jump page