SpringMvc-reset风格

1.须要在web.xml中配置一个filter <filter>   <filter-name>HiddenHttpMethodFilter</filter-name>   <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter>html

<filter-mapping>   <filter-name>HiddenHttpMethodFilter</filter-name>   <url-pattern>/*</url-pattern> </filter-mapping> 2.reset风格向后台发送数据的时候须要,若是是get就直接发送数据,若是是PUT、DELETE、POST的话须要以表单的形式来发送,而且在表单中须要加一个隐藏域 name为_method,value为请求方式 <form action="springmvc/testRestPost" method="post"> <input type="submit" value="提交POST"/> </form> <br/> <form action="springmvc/testRestDlete/1" method="post"> <input type="hidden" name="_method" value="DELETE"/> <input type="submit" value="提交DELETE"/> </form> <br/> <form action="springmvc/testRestPut/1" method="post"> <input type="hidden" name="_method" value="PUT"/> <input type="submit" value="提交PUT"/> </form> 3.GET、DELETE、PUT经过注解@PathVariable来接收参数 @RequestMapping(value="/testRestGet/{id}",method=RequestMethod.GET) public String testRestGet(@PathVariable String id){ return SUCCESS; }web

@RequestMapping(value="/testRestPost",method=RequestMethod.POST)
public String testRestPost(){
    return SUCCESS;
}

@RequestMapping(value="/testRestDlete/{id}",method=RequestMethod.DELETE)
public String testRestDlete(@PathVariable String id){
    return SUCCESS;
}

@RequestMapping(value="/testRestPut/{id}",method=RequestMethod.PUT)
public String testRestPut(@PathVariable String id){
    return SUCCESS;
}
@RequestMapping("/toJfDynamicDetail{id}.html")
public ModelAndView testPathVariable(@PathVariable("id") Long rowId, HttpServletRequest request) {
    ModelAndView mv = new ModelAndView();
    request.setAttribute("flag", 10);
    MarketingNotice marketingNotice = this.noticeService.findByPK(rowId);
    mv.addObject("marketingNotice", marketingNotice);
        List<MarketingNotice>  marketingNoticeList = noticeService.findPageByLatey();
        mv.addObject("marketingNoticeList", marketingNoticeList);
        mv.setViewName("dynamicDetail");
    return mv;
}
相关文章
相关标签/搜索