科帮网

登录/注册
您现在的位置:论坛 盖世程序员(我猜到了开头 却没有猜到结局) 盖世程序员 > springMvc配置转发请求三种方法SimpleUrlHandlerMapping
总共48087条微博

动态微博

查看: 2597|回复: 0

springMvc配置转发请求三种方法SimpleUrlHandlerMapping

[复制链接]

326

主题

72

听众

999

金钱

实习版主

该用户从未签到

优秀版主

跳转到指定楼层
楼主
发表于 2014-11-06 13:24:58 |只看该作者 |倒序浏览
  1. <?xml version="1.0" encoding="UTF-8"?>   4 {2 D) T8 y# E" R* i
  2. <beans   4 v. o  w" s6 R
  3.     xmlns="http://www.springframework.org/schema/beans"  / a3 U+ K4 n7 ^0 m% Z
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    ' H2 E0 D! Y3 {$ _, Y# {+ W4 j
  5.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">   % c' s8 m7 }# O. B
  6.       1 p2 S/ K; d" V
  7.    <bean id="loginController" class="com.spring.web.controller.LoginController"/>   # k) N8 @7 G9 m' h& V
  8.      4 f+ g& M, N/ y" S
  9.     $ U$ v0 {4 w1 }, D0 N4 _! \
  10.    <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">   9 x. ^  u$ y$ V' b, v- u
  11.    <!-- 配置方法一   
    ) z7 z' _( p5 q. Q) Y
  12.      <property name="urlMap">   
      h( ?6 s6 M) U
  13.          <map>   
    7 U* m) h% X8 x
  14.             <entry key="/user/login.do" value-ref="loginController"/>   
    : D7 C2 g- j1 w% h4 n8 i8 [' M
  15.          </map>   $ l) ]5 P$ b3 [! c
  16.      </property> -->   
    4 F0 Q3 a3 E$ W4 v% V3 r
  17.   <!-- 配置方法二   
    * ~6 G. N0 Z# a6 }
  18.     <property name="mappings">   
    + `' ?; S1 `4 v
  19.        <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">   
    9 N3 r, z4 B- ?
  20.            <property name="location">   
    8 M: v+ B+ e2 q. r+ @1 Y
  21.               <value>urlMap.properties</value <!-- 此时urlMap.properties文件应放在WebRoot目录下! -->   
    5 r# [0 w, H, j% ^. \) i
  22.            </property>   ' c; q9 V; T3 J
  23.        </bean>   
    . f& _) L4 c- G! J- g2 N
  24.     </property>   , C  O) V* W. d
  25.    -->   
      L; _$ H9 c( X
  26.    <!-- 配置方法三 -->   
    1 b" Z3 I( Q: l$ A/ v* c& s
  27.      <property name="mappings">   2 q2 _2 w$ ?5 |: }
  28.         <props>   
    4 S1 H9 c, x1 H9 w6 O  _' x) M& \
  29.            <prop key="/user/login.do">loginController</prop>   : _( a- ~1 H0 g" N4 N
  30.         </props>   + @0 {/ q$ p. L# F' y
  31.      </property></bean>   6 ^/ ~, y" w: |1 C
  32.     5 z0 G7 L% Y& f
  33.    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">   $ M( }% |2 f% A+ h2 i" B; C+ I, z
  34.      <property name="prefix"><value>/WEB-INF/jsp/</value></property>   
    6 M6 ^  u' V" p+ ~  ^& D, h/ R' U) ]
  35.      <property name="suffix"><value>.jsp</value></property>   + c4 S. P3 R0 s: d% B2 B0 H
  36.      <property name="viewClass">     j) n* _0 l( X6 Y8 X3 R  j0 I
  37.        <value>   
    ! {4 J& @! R" m& u
  38.         org.springframework.web.servlet.view.JstlView   4 f; E7 c0 n% x% ?
  39.        </value>   : ~5 _! S5 x" L5 X$ T
  40.      </property>   
    1 N# ~5 O3 s( Z* k2 x3 s  o) G
  41.    </bean>
    2 C  s4 I3 M: e- }& j8 V6 r
  42. </beans>  
    6 W3 U' m- @* x8 D1 h0 C- n: J* E
复制代码
springMvc简单的登录程序小项目 :http://www.52itstyle.top/thread-2737-1-1.html1 j. E  x/ v/ |$ b$ ~% }

科帮网 1、本主题所有言论和图片纯属会员个人意见,与本社区立场无关
2、本站所有主题由该帖子作者发表,该帖子作者与科帮网享有帖子相关版权
3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和科帮网的同意
4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
7、科帮网管理员和版主有权不事先通知发贴者而删除本文


JAVA爱好者①群:JAVA爱好者① JAVA爱好者②群:JAVA爱好者② JAVA爱好者③ : JAVA爱好者③

本帖被以下淘专辑推荐:

快速回复
您需要登录后才可以回帖 登录 | 立即注册

   

关闭

站长推荐上一条 /1 下一条

发布主题 快速回复 返回列表 联系我们 官方QQ群 科帮网手机客户端
快速回复 返回顶部 返回列表