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

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

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

    風人園

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

    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" />用于指明系統從哪個路徑下尋找controller,然后提前初始化這些對象。

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

    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路徑,通過參數指定調用的方法

    @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,都支持。

    以上是系統暫時用到的,其他的以后再研究。

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

    主站蜘蛛池模板: 亚洲国产精品xo在线观看| 在线a亚洲v天堂网2018| 91精品免费观看| 日本一道本不卡免费 | 精品亚洲一区二区三区在线播放| 国产成人精品免费直播| 国产成人免费手机在线观看视频| 在线免费观看一级片| 麻豆精品国产免费观看| 亚洲&#228;v永久无码精品天堂久久| 国产免费无遮挡精品视频| 日产乱码一卡二卡三免费| 国产99视频精品免费视频7| 亚洲精品无码久久不卡| 中文字幕人成人乱码亚洲电影| 国内精品久久久久久久亚洲| 国产精品亚洲成在人线| 亚洲图片一区二区| 亚洲二区在线视频| 亚洲国产精品无码久久| 四虎精品免费永久免费视频| 国产免费高清69式视频在线观看| 怡红院免费的全部视频| 免费人成在线观看网站| 日本在线高清免费爱做网站| 午夜一级毛片免费视频| 亚洲国产精品狼友中文久久久| 亚洲精品无码成人AAA片| 久久亚洲私人国产精品| 中文字幕亚洲男人的天堂网络 | 亚洲综合丁香婷婷六月香| 亚洲人成www在线播放| 亚洲精品永久在线观看| 一级做a爰全过程免费视频毛片| 久久免费高清视频| 久久www免费人成看片| 四虎影视精品永久免费| 亚洲精品美女久久777777| 亚洲欧洲日本天天堂在线观看| MM1313亚洲精品无码久久| 国产自国产自愉自愉免费24区|