0
votes

I'm building spring mvc application with spring security. This is my url :

http://localhost:8080/inbalUI/login

And I'm getting to my controller :

@RequestMapping(value = "/login", method = RequestMethod.GET)
       public String loginPage() {
             if (isCurrentAuthenticationAnonymous()) {
                    return "login";
             } else {
                    return "login";
                    // return "redirect:/list";
             }
       }

This is the log :

20:02:10.823 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/login.jsp] in InternalResourceView 'login' 20:02:10.825 [http-nio-8080-exec-10] DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 20:02:10.825 [http-nio-8080-exec-10] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request 20:02:10.825 [http-nio-8080-exec-10] DEBUG org.springframework.security.web.access.ExceptionTranslationFilter - Chain processed normally 20:02:10.825 [http-nio-8080-exec-10] DEBUG org.springframework.security.web.context.SecurityContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed

This is the login.jsp deploying path on tomcat :

C:\me\apache\apache-tomcat-8.0.36\webapps\inbalUI\WEB-INF\classes\WEB-INF\views

But I'm getting HTTP Status 404:

HTTP Status 404 - /inbalUI/WEB-INF/views/login.jsp type Status report message /inbalUI/WEB-INF/views/login.jsp description The requested resource is not available.


Apache Tomcat/8.0.36

Any idea why ?

1
Because the jsp should be at /WEB-INF/views/login.jsp, not at WEB-INF/classes/WEB-INF/views/login.jsp. - JB Nizet
yes I fixed my deployment assembly and now it works. Thanks! - user7916020

1 Answers

1
votes

It seems to me that you use the wrong folder for views.

According to this article https://vitalflux.com/web-application-folder-structure-spring-mvc-web-projects/ this folder should be at:

src/WEB-INF/views/login.jsp

and you probably put it under

src/resources/WEB-INF/views/login.jsp

Which results in WEB-INF/views/login.jsp being put into the classpath (classes/WEB-INF/views/login.jsp)