<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    風人園

    弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
    隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
    數(shù)據加載中……

    Spring MVC Annotation

    spring mvc 使用annotation進行controller配置
    注:兩種urlmapping的模式不能同時使用,如果使用annotation就不能再配置springapp-servlet.xml的urlmapping。

    1、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:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-2.5.xsd">

        <context:component-scan base-package="com.ivo.web.action.spring" />
     
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
            <property name="prefix"><value>/pages/</value></property>
            <property name="suffix"><value>.jsp</value></property>
        </bean>
       
    </beans>

        <context:component-scan base-package="com.ivo.web.action.spring" />用于指明系統(tǒng)從哪個路徑下尋找controller,然后提前初始化這些對象。

    2、web.xml
        跟一般的mvc配置沒有區(qū)別。

    3、controller配置
        具體可以看spring的參考文件,有好幾種配置。

        3.1 在方法上配置mapping路徑
            

    @Controller
    public class HelloController {

     @RequestMapping("/hello.do")
     public ModelAndView processImageUpload() throws IOException {
      System.out.println("hello");
      return new ModelAndView("org", "jsonString", "test");
     }

    }

        3.2 在class上配置mapping路徑,通過參數(shù)指定調用的方法

    @Controller
    @RequestMapping("/hello.do")
    public class HelloController {

    @RequestMapping(params = "action=save")
     public ModelAndView save() throws IOException {
      System.out.println("hello");
      return new ModelAndView("org", "jsonString", "test");
     }

    }

    方法的返回值可以是null,string 或者ModelAndView,都支持。

    以上是系統(tǒng)暫時用到的,其他的以后再研究。

    posted on 2008-01-10 13:35 風人園 閱讀(1818) 評論(0)  編輯  收藏 所屬分類: Spring

    主站蜘蛛池模板: 久久久久久影院久久久久免费精品国产小说 | 小说专区亚洲春色校园| 免费A级毛片无码A∨男男| 中文字幕免费播放| 亚洲成人免费电影| 四虎国产精品免费久久影院| 亚洲免费观看视频| 亚洲人成人伊人成综合网无码| 亚洲人成色77777在线观看大| 一区二区三区在线免费看| 亚洲av无码专区在线电影天堂 | 亚洲av无码专区首页| 国产成人亚洲精品狼色在线| 亚洲一区二区三区免费视频| 美女扒开尿口给男人爽免费视频| 亚洲AV无码一区二区三区系列 | xxxxwww免费| 国产精品成人免费观看| 亚洲午夜国产精品无卡| 亚洲一级特黄大片无码毛片| 免费黄色福利视频| 91免费福利视频| 亚洲GV天堂无码男同在线观看| 亚洲国产成人久久综合一| vvvv99日韩精品亚洲| 野花高清在线观看免费完整版中文 | 亚洲性69影院在线观看| 亚洲午夜国产精品无码老牛影视| 天天看片天天爽_免费播放| 少妇人妻偷人精品免费视频| 一个人免费观看日本www视频 | 精品无码免费专区毛片| 国产一级高青免费| 国产精品亚洲а∨天堂2021 | 亚洲精品日韩中文字幕久久久| 亚洲日本中文字幕天堂网| 麻豆国产入口在线观看免费| 亚洲网站免费观看| 久久精品一本到99热免费| 中国人免费观看高清在线观看二区 | 亚洲一区二区三区亚瑟|