JAVA-1529: Add MVC config
This commit is contained in:
parent
34c18aefc4
commit
daa42ab3a0
@ -26,14 +26,22 @@
|
|||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>${spring.mvc.version}</version>
|
<version>${spring.mvc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>spring-mvc-java-2</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<javax.version>4.0.1</javax.version>
|
<javax.version>4.0.1</javax.version>
|
||||||
<spring.mvc.version>5.2.2.RELEASE</spring.mvc.version>
|
<spring.mvc.version>5.2.2.RELEASE</spring.mvc.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -4,8 +4,9 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Controller
|
@RestController
|
||||||
@RequestMapping("/site")
|
@RequestMapping("/site")
|
||||||
public class SiteController {
|
public class SiteController {
|
||||||
|
|
||||||
|
17
spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml
Normal file
17
spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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"
|
||||||
|
xsi:schemaLocation="
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||||
|
<!-- <mvc:annotation-driven/>-->
|
||||||
|
|
||||||
|
<context:component-scan base-package="com.baeldung"/>
|
||||||
|
</beans>
|
22
spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml
Normal file
22
spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xsi:schemaLocation="https://xmlns.jcp.org/xml/ns/javaee https://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
|
||||||
|
<display-name>Spring MVC Application 2</display-name>
|
||||||
|
<!-- Add Spring MVC DispatcherServlet as front controller -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>mvc</servlet-name>
|
||||||
|
<servlet-class>
|
||||||
|
org.springframework.web.servlet.DispatcherServlet
|
||||||
|
</servlet-class>
|
||||||
|
<init-param>
|
||||||
|
<param-name>contextConfigLocation</param-name>
|
||||||
|
<param-value>/WEB-INF/mvc-servlet.xml</param-value>
|
||||||
|
</init-param>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>mvc</servlet-name>
|
||||||
|
<url-pattern>/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
</web-app>
|
Loading…
x
Reference in New Issue
Block a user