This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class WebAppIntializer implements WebApplicationInitializer { | |
| @Override | |
| public void onStartup(ServletContext servletContext) throws ServletException { | |
| //parent | |
| AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); | |
| rootContext.register(AppConfig.class); | |
| servletContext.addListener(new ContextLoaderListener(rootContext)); | |
| // new ContextLoader(rootContext).initWebApplicationContext(servletContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @EnableTransactionManagement | |
| @ComponentScan(basePackages = "whiteship", excludeFilters = {@ComponentScan.Filter(Configuration.class), @ComponentScan.Filter(Controller.class)}) | |
| public class AppConfig { | |
| @Bean(destroyMethod = "shutdown") | |
| public DataSource dataSource(){ | |
| return new EmbeddedDatabaseBuilder() | |
| .setName("bookDB") | |
| .setType(EmbeddedDatabaseType.H2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @EnableWebMvc | |
| @ComponentScan(basePackages = "whiteship", | |
| useDefaultFilters = false, | |
| includeFilters = @ComponentScan.Filter(Controller.class)) | |
| public class WebConfig extends WebMvcConfigurerAdapter { | |
| @Override | |
| public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { | |
| configurer.enable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <dependency> | |
| <groupId>javax.servlet</groupId> | |
| <artifactId>servlet-api</artifactId> | |
| <version>3.0</version> | |
| <scope>provided</scope> | |
| </dependency> | |
| <dependency> | |
| <groupId>javax</groupId> | |
| <artifactId>javaee-api</artifactId> | |
| <version>6.0</version> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebServlet(urlPatterns = "/test") | |
| public class TestServlet extends HttpServlet { | |
| @Override | |
| protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | |
| res.setContentType(MediaType.TEXT_PLAIN_VALUE); | |
| PrintWriter out = res.getWriter(); | |
| out.write("Hello"); | |
| out.close(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebServlet(urlPatterns = "/spring/*", | |
| initParams = { | |
| @WebInitParam(name = "contextConfigLocation", value = "classpath*:/spring.xml")}) | |
| public class SpringServlet extends DispatcherServlet { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @WebServlet("/upload") | |
| @MultipartConfig(location = "/tmp") | |
| public class FileUploadServlet extends HttpServlet { | |
| @Override | |
| protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { | |
| getServletContext().getRequestDispatcher("/WEB-INF/views/fileUpload.jsp").forward(req, res); | |
| } | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package me.whiteship.board.modules.servlet.async; | |
| import javax.servlet.AsyncContext; | |
| import javax.servlet.AsyncEvent; | |
| import javax.servlet.AsyncListener; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.annotation.WebServlet; | |
| import javax.servlet.http.HttpServlet; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package sandbox.testcontext.config; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| /** | |
| * @author Keesun Baik | |
| */ | |
| @Configuration | |
| public class AppConfig { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| public class AppConfig extends HelloConfig { | |
| @Override | |
| public Hello hello() { | |
| Hello h = super.hello(); | |
| h.setName("Keesun"); | |
| return h; | |
| } | |
| } |
OlderNewer