乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Spring MVC中RequestMapping的各種用法

       時(shí)間要去哪 2014-05-22
      package com.lee.study.spring.mvc.web;
         
      import javax.servlet.http.HttpServletRequest;
         
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.Model;
      import org.springframework.web.bind.annotation.CookieValue;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestHeader;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.servlet.ModelAndView;
         
      import com.lee.study.spring.mvc.domain.User;
         
      @Controller
      @RequestMapping("/owners/{ownerId}")
      public class PelativePathUnTemplateController {
          /**
           * 這個(gè)方法使用URL通配符的方式,遵守REST風(fēng)格傳遞了多個(gè)參數(shù)
           * @param ownerId
           * @param petId
           * @param model
           */
          @RequestMapping("/pets/{petId}")
          public void findPet(@PathVariable String ownerId,@PathVariable String petId,Model model){
              //do something
          }
          /**
           * 請(qǐng)求參數(shù)按照名稱匹配的方式綁定到方法參數(shù)中,方法返回的字符串代表邏輯視圖
           * @param userName
           * @param passworld
           * @param realName
           * @return
           */
          @RequestMapping("/handle1")
          public String handle1(@RequestParam("userName") String userName,
                                @RequestParam("passworld") String passworld,  
                                @RequestParam("realName") String realName
                  ){
              return "success";
          }
          /**
           * 取出cookie中的值和請(qǐng)求報(bào)頭中的值綁定到方法參數(shù)中
           * @param sessionId
           * @param accpetLanguage
           * @return
           */
          @RequestMapping("/handle2")
          public ModelAndView handle2(
                      @CookieValue("JSESSIONID") String sessionId,
                      @RequestHeader("Accept-Language") String accpetLanguage
                  ){
              ModelAndView mav = new ModelAndView();
              mav.setViewName("/success");
              mav.addObject("user",new User());
              return null;
          }
          /**
           * 請(qǐng)求參數(shù)按照名稱匹配綁定到user的屬性中.
           * @param user
           * @return
           */
          @RequestMapping("/handle3")
          public String handle3(User user){
              //do something
              return "success";
          }
          /**
           * 直接把request對(duì)象傳入到方法參數(shù)中,由此我們可以獲取請(qǐng)求中許多東西
           * @param request
           * @return
           */
          @RequestMapping("/handle4")
          public String handle4(HttpServletRequest request){
              //do something
              return "success";
          }
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多