1.创建后台配置文件springmvc-back.xml
1
2
3
4
5
6
7
8
9
10
11
|
<
context:component-scan
base-package
=
"cn.liu"
use-default-filters
=
"false"
>
<
context:include-filter
type
=
"annotation"
expression
=
"org.springframework.stereotype.Controller"
/>
</
context:component-scan
>
<!-- jsp视图 -->
<
bean
id
=
"jspViewResolver"
class
=
"org.springframework.web.servlet.view.InternalResourceViewResolver"
>
<
property
name
=
"prefix"
value
=
"/WEB-INF/back_page/"
/>
<
property
name
=
"suffix"
value
=
".jsp"
/>
</
bean
>
|
2.创建前台配置文件springmvc-front.xml
1
2
3
4
5
6
7
8
9
10
11
|
<
context:component-scan
base-package
=
"cn.liu"
use-default-filters
=
"false"
>
<
context:include-filter
type
=
"annotation"
expression
=
"org.springframework.stereotype.Controller"
/>
</
context:component-scan
>
<!-- jsp视图 -->
<
bean
id
=
"jspViewResolver"
class
=
"org.springframework.web.servlet.view.InternalResourceViewResolver"
>
<
property
name
=
"prefix"
value
=
"/WEB-INF/back_page/"
/>
<
property
name
=
"suffix"
value
=
".jsp"
/>
</
bean
>
|
3.配置web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<!-- springmvc 后台配置 -->
<
servlet
>
<
servlet-name
>back</
servlet-name
>
<
servlet-class
>org.springframework.web.servlet.DispatcherServlet</
servlet-class
>
<
init-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>classpath:springmvc-back.xml</
param-value
>
</
init-param
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>back</
servlet-name
>
<
url-pattern
>*.do</
url-pattern
>
</
servlet-mapping
>
<!-- springmvc 前台配置 -->
<
servlet
>
<
servlet-name
>front</
servlet-name
>
<
servlet-class
>org.springframework.web.servlet.DispatcherServlet</
servlet-class
>
<
init-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>classpath:springmvc-front.xml</
param-value
>
</
init-param
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>front</
servlet-name
>
<
url-pattern
>*.shtml</
url-pattern
>
</
servlet-mapping
>
|
版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任
本文转自 l363130002 51CTO博客,原文链接:http://blog.51cto.com/liuyj/1712021