为了账号安全,请及时绑定邮箱和手机立即绑定

为什么war包在Windows的tomcat正常运行,在linux服务器报errorpage错误?

为什么war包在Windows的tomcat正常运行,在linux服务器报errorpage错误?

木子锦 2019-08-19 10:55:11
最近项目完成后打包成war发布到服务器遇到访问应用404问题,用的是tomcat8.5,错误信息如下: o.s.b.w.servlet.support.ErrorPageFilter  : Cannot forward to error page for request [/login] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false项目是springboot+security+mybatis,ide 用的idea,打包方式用的是build菜单中的Build Artifactissecurity配置protected void configure(HttpSecurity http) throws Exception {     http.authorizeRequests()                 //处理preflight请求                 //.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()                 .antMatchers("/user/login").permitAll()                 .antMatchers("/login").permitAll()                 .antMatchers("/login/error").permitAll()                 .anyRequest().authenticated()                 .and()                 //设置登录页             .formLogin()                 //设置登录成功页                 .loginPage("/login")                 .successHandler(securityLoginSuccessHandler)                 .failureHandler(securityLoginFailureHandler)                 .and()             .logout()                 .logoutUrl("/logout")                 .logoutSuccessHandler(securityLogoutSuccessHandler)                 .deleteCookies("JSESSIONID")                 .and()             .sessionManagement()                 //session超时处理                 .invalidSessionUrl("/login/invalid")                 .maximumSessions(1)                 //老用户被踢出后操作                 .expiredSessionStrategy(new SecurityExpiredSessionStrategy());     http.csrf().disable()             .exceptionHandling().accessDeniedHandler(securityAccessDeniedHandler); }loginpage的“/login”配置如下:@RequestMapping("/login") public String  showLogin() throws IOException {     System.out.println("调用loginController的登录方法");     return "index.html#/login"; }在启动类加入配置:public class KpApplication extends SpringBootServletInitializer {     public static void main(String[] args) {         SpringApplication.run(KpApplication.class, args);     }     @Bean     public ErrorPageFilter errorPageFilter() {         return new ErrorPageFilter();     }     @Bean     public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {         FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();         filterRegistrationBean.setFilter(filter);         filterRegistrationBean.setEnabled(false);         return filterRegistrationBean;     } } 重新打包发布到linux服务器,新的错误信息为: o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATION FAILED TO START***************************Description:The bean 'errorPageFilter', defined in org.springframework.boot.web.servlet.support.ErrorPageFilterConfiguration, could not be registered. A bean with that name has already been defined in com.kpzdh.kp.KpApplication and overriding is disabled.Action:Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true然后在yml配置中加入配置:spring:   jmx:     default-domain: demo   datasource:     driver-class-name: com.mysql.cj.jdbc.Driver     url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8     username: root     password: root   main:     allow-bean-definition-overriding: true      如上配置之后,两个错误信息都没有出现了,但是还是404,查看日志,"/login"路径的"调用loginController的登录方法"已经输出了, 但是浏览器控制台中,/login路径还是404,请问该如何解决呢?这个问题已经困扰很久了,希望大家能帮帮我,万分感谢!
查看完整描述
  • 3 回答
  • 0 关注
  • 4456 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信