我在application.properties中将contextPath设置为带 spring 安全性的spring boot应用程序中的server.contextPath = / myWebApp,默认url为/ login它不将上下文路径设置为/ myWebApp,并将我重定向为/ login而不是/ myWebApp / login . 如何使用spring security 4.0设置contextPath?由于tomcat作为context []发出警告..没有在容器中部署app .
2 回答
我在 Application.properties 文件中设置 server.servlet.context-path 解决了这个问题
代码示例
Application.properties
server.servlet.context-path=/myWebApp/
有了这个,您还可以根据需要实现登录页面http://localhost:8080/myWebApp/login
在Spring Boot中,您可以通过3种方式设置上下文路径 .
First in application.properties 就像你一样 .
Second the change can be done programmatically as well:
And Finally, by passing the system properties directly:
Spring Security Config is:
并且没有任何进一步的更改,tomcat将自动启动
/myWebApp/login