Java video parsing series 001: Spring MVC entry: Hello World, 001mvc
Spring download
Http://projects.spring.io/spring-framework/
Install spring
There are two ways to create a project. We recommend that you use maven project to better control jar package dependencies.
Dynamic web project Method
Make the following configurations in maven (for maven, refer to the maven article on this site ). For details about how to convert a dynamic web project to maven, see eclipse java project and maven project to add spring mvc to each other. Simply add the following code to pom. xml:
<!--spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.13.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.13.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.13.RELEASE</version>
</dependency>
Note that you need to update the eclipse project after adding it.
Maven Project Method Project Structure
Configuration and Hello World based on maven
1. Modify pom. xml and add necessary Dependencies
2. Add a configuration file
ApplicationContext. xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
</beans>
SpringMVC-servlet.xml
<? Xml version ="1.0"Encoding =UTF-8"?>
<Beans xmlns =Http://www.springframework.org/schema/beans"
Xmlns: xsi =Http://www.w3.org/2001/XMLSchema-instance"Xmlns: context =Http://www.springframework.org/schema/context"
Xmlns: mvc =Http://www.springframework.org/schema/mvc"
Xsi: schemaLocation ="
Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context.xsd
Http://www.springframework.org/schema/mvc
Http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<! -- Specify the automatic scan path -->
<Context: component-scan base-package ="Com. terwer. player. action"> </Context: component-scan>
<! -- View parser, using jstl -->
<Bean id ="ViewResolver"
Class ="Org. springframework. web. servlet. view. UrlBasedViewResolver">
<Property name ="ViewClass"
Value ="Org. springframework. web. servlet. view. JstlView"/>
<Property name ="Prefix"Value =/WEB-INF/views /"/>
<Property name ="Suffix"Value =". Jsp"/>
</Bean>
</Beans>
Web. xml
<! DOCTYPE web-app PUBLIC
"-// Sun Microsystems, Inc. // DTD Web Application 2.3 // EN"
Http://java.sun.com/dtd/web-app_2_3.dtd>
<Web-app>
<Display-name> Archetype Created Web Application </display-name>
<! -- Spring listener -->
<Listener>
<Listener-class> org. springframework. web. context. ContextLoaderListener </listener-class>
</Listener>
<! -- Spring MVC interceptor -->
<Servlet>
<Servlet-name> springMvc </servlet-name>
<Servlet-class> org. springframework. web. servlet. DispatcherServlet </servlet-class>
<Init-param>
<Param-name> contextConfigLocation </param-name>
<Param-value>/WEB-INF/SpringMVC-servlet.xml </param-value>
</Init-param>
<Load-on-startup> 1 </load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-name> springMvc </servlet-name>
<Url-pattern>/</url-pattern>
</Servlet-mapping>
</Web-app>
3. Add page index. jsp in WEB-INF/views
Traditional Mode
Refer to maven
Run in the browser and enter
Http: // localhost: 8080/player/home/index
Effect
Download all source code
Series navigation
Http://www.terwer.com/special.html#use Java real-time video address resolution