Integration of the phase 3 3.SpringMVC · _07.SSM case _04.ssm integration framework written SpringMVC

 SpringMvc built environment,

The first is to provide a front end controller



 Reconfiguration serletMapping

Load Springmvc.xml profile


Use init-param inside a property contextConfigLocation

not yet springmvc.xml this document, we will want to create a springmvc.xml

Start the server creates the servlet

Solve the Chinese garbled

Configuring a filter

what filter bar. Mapping-filter.
/ *: indicates what bar

to set a specific set of encoding



has the property of encoding


the above filter on the front-end controller and the configuration

New springmvc.xml

New resources folder



completion of the constraints inside sprinmvc.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

We need to configure a total of four places

Open comments Scan


Scan only the annotation Controller

View resolver configuration

InternalResurceViewResolver view parser object

which has two properties, the first one is the prefix


file extension

swap places, just written backwards.

Configuring static resources

 

<!-- 设置静态资源不过滤 -->
<mvc:resources location="/css/" mapping="/css/**" />
<mvc:resources location="/images/" mapping="/images/**" />
<mvc:resources location="/js/" mapping="/js/**" />

Open mvc annotation support

test

Delete the original page, where the new .index.jsp page





New pages folder, the following new list.jsp page

deploy





Start the server

test






Guess you like

Origin www.cnblogs.com/wangjunwei/p/11388098.html
Recommended