extract spring-mvc-basics-2 module
This commit is contained in:
parent
e848a0ffcf
commit
5182035762
@ -15,14 +15,11 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||||||
- [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor)
|
- [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor)
|
||||||
- [What’s New in Spring 4.3?](http://www.baeldung.com/whats-new-in-spring-4-3)
|
- [What’s New in Spring 4.3?](http://www.baeldung.com/whats-new-in-spring-4-3)
|
||||||
- [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring)
|
- [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring)
|
||||||
- [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers)
|
|
||||||
- [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes)
|
- [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes)
|
||||||
- [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope)
|
- [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope)
|
||||||
- [A CLI with Spring Shell](http://www.baeldung.com/spring-shell-cli)
|
- [A CLI with Spring Shell](http://www.baeldung.com/spring-shell-cli)
|
||||||
- [JasperReports with Spring](http://www.baeldung.com/spring-jasper)
|
- [JasperReports with Spring](http://www.baeldung.com/spring-jasper)
|
||||||
- [Model, ModelMap, and ModelView in Spring MVC](http://www.baeldung.com/spring-mvc-model-model-map-model-view)
|
|
||||||
- [@Order in Spring](http://www.baeldung.com/spring-order)
|
- [@Order in Spring](http://www.baeldung.com/spring-order)
|
||||||
- [Spring Web Contexts](http://www.baeldung.com/spring-web-contexts)
|
|
||||||
- [Spring @Primary Annotation](http://www.baeldung.com/spring-primary)
|
- [Spring @Primary Annotation](http://www.baeldung.com/spring-primary)
|
||||||
- [Spring Events](https://www.baeldung.com/spring-events)
|
- [Spring Events](https://www.baeldung.com/spring-events)
|
||||||
- [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations)
|
- [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations)
|
||||||
|
13
spring-mvc-basics-2/.gitignore
vendored
Normal file
13
spring-mvc-basics-2/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
*.class
|
||||||
|
|
||||||
|
#folders#
|
||||||
|
/target
|
||||||
|
/neoDb*
|
||||||
|
/data
|
||||||
|
/src/main/webapp/WEB-INF/classes
|
||||||
|
*/META-INF/*
|
||||||
|
|
||||||
|
# Packaged files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
11
spring-mvc-basics-2/README.md
Normal file
11
spring-mvc-basics-2/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
=========
|
||||||
|
|
||||||
|
## Spring MVC Basics with Java Configuration Example Project
|
||||||
|
|
||||||
|
### The Course
|
||||||
|
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers)- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
|
||||||
|
- [Model, ModelMap, and ModelView in Spring MVC](http://www.baeldung.com/spring-mvc-model-model-map-model-view)
|
||||||
|
- [Spring Web Contexts](http://www.baeldung.com/spring-web-contexts)
|
37
spring-mvc-basics-2/pom.xml
Normal file
37
spring-mvc-basics-2/pom.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>spring-mvc-basics-2</artifactId>
|
||||||
|
<name>spring-mvc-basics-2</name>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -2,7 +2,6 @@ package com.baeldung.contexts.config;
|
|||||||
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
|
||||||
|
|
||||||
public class AnnotationsBasedApplicationAndServletInitializer //extends AbstractDispatcherServletInitializer
|
public class AnnotationsBasedApplicationAndServletInitializer //extends AbstractDispatcherServletInitializer
|
||||||
{
|
{
|
@ -1,6 +1,5 @@
|
|||||||
package com.baeldung.contexts.config;
|
package com.baeldung.contexts.config;
|
||||||
|
|
||||||
import org.springframework.web.context.AbstractContextLoaderInitializer;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
|
|
@ -2,7 +2,6 @@ package com.baeldung.contexts.config;
|
|||||||
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
|
||||||
|
|
||||||
public class SecureAnnotationsBasedApplicationAndServletInitializer// extends AbstractDispatcherServletInitializer
|
public class SecureAnnotationsBasedApplicationAndServletInitializer// extends AbstractDispatcherServletInitializer
|
||||||
{
|
{
|
@ -4,12 +4,8 @@ import javax.servlet.ServletContext;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRegistration;
|
import javax.servlet.ServletRegistration;
|
||||||
|
|
||||||
import org.springframework.context.support.GenericApplicationContext;
|
|
||||||
import org.springframework.web.WebApplicationInitializer;
|
|
||||||
import org.springframework.web.context.ContextLoaderListener;
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
|
|
||||||
public class StudentControllerConfig //implements WebApplicationInitializer
|
public class StudentControllerConfig //implements WebApplicationInitializer
|
@ -10,7 +10,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
public class RestController {
|
public class RestController {
|
||||||
|
|
||||||
@GetMapping(value = "/student/{studentId}")
|
@GetMapping(value = "/student/{studentId}")
|
||||||
public @ResponseBody Student getTestData(@PathVariable Integer studentId) {
|
public @ResponseBody
|
||||||
|
Student getTestData(@PathVariable Integer studentId) {
|
||||||
Student student = new Student();
|
Student student = new Student();
|
||||||
student.setName("Peter");
|
student.setName("Peter");
|
||||||
student.setId(studentId);
|
student.setId(studentId);
|
@ -0,0 +1 @@
|
|||||||
|
spring.main.allow-bean-definition-overriding=true
|
13
spring-mvc-basics-2/src/main/resources/logback.xml
Normal file
13
spring-mvc-basics-2/src/main/resources/logback.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
24
spring-mvc-basics-2/src/test/resources/test-mvc.xml
Normal file
24
spring-mvc-basics-2/src/test/resources/test-mvc.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:p="http://www.springframework.org/schema/p"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-4.0.xsd
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
|
||||||
|
<context:component-scan base-package="org.baeldung.controller.controller" />
|
||||||
|
<mvc:annotation-driven />
|
||||||
|
|
||||||
|
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||||
|
<property name="prefix">
|
||||||
|
<value>/WEB-INF/</value>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<value>.jsp</value>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</beans>
|
Loading…
x
Reference in New Issue
Block a user