package org.springside.examples.quickstart;

import com.opensymphony.sitemesh.webapp.SiteMeshFilter;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import javax.servlet.Filter;
import javax.validation.Validator;
import java.io.*;

@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
//@Configuration定义配置类
//you can use @ComponentScan to automatically pickup all Spring components, including @Configuration classes.
public class Application {

    public static void main(String[] args) throws FileNotFoundException {
        SpringApplication app = new SpringApplication(Application.class);
        app.run(args);

    }

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/WEB-INF/views/error/401.jsp");
                ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/WEB-INF/views/error/404.jsp");
                ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/WEB-INF/views/error/500.jsp");

                container.addErrorPages(error401Page, error404Page, error500Page);
            }
        };
    }

    @Bean
    //JSR303 Validator定义
    public Validator localValidatorFactoryBean() {
        return new LocalValidatorFactoryBean();
    }

    @Bean
    public Filter sitemeshFilter() {
        return new SiteMeshFilter();
    }

}
@@ -1080,32 +1080,8 @@
     
- SpringApplication app =
  new
@@ -1121,21 +1121,8 @@
 ass)
-;%0A        app
 .run
@@ -1129,17 +1129,16 @@
 (args);%0A
-%0A
     %7D%0A%0A 

improve it.