Springboot+tomcat page transition is not possible

Asked 2 months ago, Updated 2 months ago, 3 views

I am currently creating a web app using SpringSecurity with SpringBoot (version 2.1.4.RELEASE).I was planning to display the login page first and transition to page 2 (top) upon successful authentication.

Launch tomcat and the app on your local PC and type url from your browser to display the login page and transition to the page.The log at that time is as follows:

2019-09-04 13:45.344 INFO216 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet: Completed initialization in 15 ms
2019-09-04 13:36:50.503 INFO216 --- [nio-8080-exec-5] o.h.h.i.QueryTranslatorFactoryInitiator: HH000397: Using ASTQueryTranslatorFactory
2019-09-04 13:36:50.950 DEBUG216 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet: GET "/xxx/", parameters={}
2019-09-04 13:36:50.956 DEBUG216 --- [nio-8080-exec-8] s.w.s.m.a.RequestMappingHandlerMapping: Mapped to public java.lang.Stringyyyy.TopController.index (org.springframework.ui.Model)
2019-09-04 13:36:50.992 DEBUG216 --- [nio-8080-exec-8] o.s.w.s.v.ContentNegotiatingViewResolver: Selected'text/html'given [text/html, application/xhtml+xml, image/webp, image/apng, application/sign-qange;vml=0/xml;application,xml;vml=0/qml
2019-09-04 13:36:51.299 DEBUG216 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet: Completed 200 OK

Generate war for this app, deploy it to the Linux server (running tomcat8) and the login page will be displayed when you run it, so enter your credentials and click ok to display the error without transitioning to the next page.

The server application logs are as follows:

 September 4, 2019 04:24:00 INFO [ajp-nio-8009-exec-1] [ ] - Completed initialization in 28 ms

The error message is as follows:

 404 Not Found
The requested URL /xxx/login was not found on this server.

The GET log like the local PC does not print and cannot transition to the next page.
Please let me know if there are any necessary settings to deploy the SpringBoot web app to the server.

The sources are as follows:
<Security Adapters>

public class WebSecurityConfig extensions WebSecurityConfigurerAdapter {
    @ Override
      protected void configure(HttpSecurity http)throws Exception {
                // login allows access
                .loginPage("/login").usernameParameter("user").passwordParameter("password")//Login Page
                .defaultSuccessUrl("/top", true)//Transition destination page upon successful authentication
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout**")) // Path of the logout operation
                // Cookie name to delete when logging out
                .deleteCookies ("JSESSIONID")
                // Enable session discard on logout
                // Transition destination when session is invalid

<page 2>

public class TopController {
    @RequestMapping (value={"/"}, method=RequestMethod.GET)
    public String index (Model model) {
        return "top";

Thank you for your cooperation.


2022-09-30 13:44

1 Answers

Resolved by setting url, same as war folder name in tomcat configuration

2022-09-30 13:44

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.