我有一个使用spring xml的遗留应用程序,我正在迁移到spring-boot.
应用程序启动,我获得了身份验证页面,映射到applicationContext-login.xml中.登录成功后,它应该加载WEB-INF / client / home.jsp,但是,它尝试加载/WEB-INF/auth/home.jsp,我得到404.
在启动日志中,我看到它映射了所有路径.为什么在这些重定向上存在冲突,我该怎么做才能解决这个问题?由于多个包含视图解析器的@ImportResource会遇到问题吗?
从安全性http配置中提取:
Failed=true"
default-target-url="/auth/defaultEntry"/>
logout logout-url="/auth/logout" logout-success-url="/auth/logout-success" delete-cookies="jsessionid"/>
它指向的控制器:
@RequestMapping(value = "/defaultEntry",method = RequestMethod.GET)
public String defaultEntry() {
if (authentication.isAuthenticated()) {
return "redirect:/client/home";
} else {
return "redirect:login";
}
}
该应用程序在xml文件中配置了多个视图解析器:
> classpath *:/ springContext / applicationContext-login.xml
> classpath *:/ springContext / applicationContext-client.xml“
还有一些其他人遵循相同的配置模式.
我正在加载Application.java中的资源
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
//@EnableWebMvc
@ComponentScan({"org.myCompany"})
@ImportResource({"classpath*:/springContext/applicationContext-controllers.xml","classpath*:/springContext/applicationContext-rest.xml","classpath*:/springContext/applicationContext-login.xml","classpath*:/springContext/applicationContext-client.xml","classpath*:/springContext/applicationContext-admin.xml","classpath*:/springContext/applicationContext-logging.xml","classpath*:/springContext/applicationContext-web-common.xml"
})
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(Application.class);
ApplicationContext ctx = app.run(args);
Environment env = ctx.getEnvironment();
logger.info(String.format("\n----------------------------------------------------------\n\t" +
"Application '%s' is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:%s\n\t" +
"External: \thttp://%s:%s\n----------------------------------------------------------",env.getProperty("spring.application.name"),env.getProperty("server.port"),InetAddress.getLocalHost().getHostAddress(),env.getProperty("server.port")));
}
@Bean
public ServletRegistrationBean restDispatcher() {
ServletRegistrationBean registration = new ServletRegistrationBean(new DispatcherServlet(),"/rest/*","/websocket/*");
registration.setName("rest-dispatcher");
registration.setLoadOnStartup(2);
Map
最佳答案