日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

spring MVC(2)--注解Hello World

發布時間:2024/9/20 c/c++ 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring MVC(2)--注解Hello World 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么80%的碼農都做不了架構師?>>> ??

  • 定義Controller,增加注解@Controller

  • package?com.zte.controller2; import?org.springframework.stereotype.Controller; import?org.springframework.web.bind.annotation.RequestMapping; import?org.springframework.web.servlet.ModelAndView; /****?@author?WuBaoGui*/ @Controller public?class?HelloController {@RequestMapping(value="/hello1")public?ModelAndView?helloWorld(){//1、收集參數//2、綁定參數到命令對象//3、調用業務對象//4、選擇下一個頁面ModelAndView?mv?=?new?ModelAndView();//添加模型數據可以是任意的POJO對象mv.addObject("message",?"Hello?World!");//設置邏輯視圖名,視圖解析器會根據該名字解析到具體的視圖頁面mv.setViewName("hello");return?mv;} }


    ????2. XML增加如下配置

    <?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc"?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/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"><!--????<bean?class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"?/>???????????<bean?class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"?/>-->???<bean?class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/><bean?class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/><!--?v3.1?<bean?class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"?/><bean?class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"?/>--><bean?class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property?name="viewClass"?value="org.springframework.web.servlet.view.JstlView"?/><property?name="prefix"?value="/WEB-INF/jsp/"?/><property?name="suffix"?value=".jsp"?/>?</bean><bean?name="/hello"?class="com.zte.controller.HelloController"/><!--?處理器--><bean?class="com.zte.controller2.HelloController"/> </beans>

    ? ? 3. 注冊Bean

    <bean?class="com.zte.controller2.HelloController"/>


    轉載于:https://my.oschina.net/looten/blog/305600

    總結

    以上是生活随笔為你收集整理的spring MVC(2)--注解Hello World的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。