HTML 接受Action中HttpServletRequest对象所带参数

方法1:

js:

var id = [[${id}]] ;// id为参数名
方法2:

Action:

 @RequestMapping(value = "/companyUnder")
    public String companyUnder(HttpServletRequest retuest,@RequestParam Integer arttypeId) {
    	    retuest.setAttribute("arttypeId", arttypeId);
    return "/staff/company/company_under";
    }

Js:


GetRequest:function(){

   var url = decodeURI(location.search); //获取到Url并且解析Url编码
   var theRequest = new Object();
   if (url.indexOf("?") != -1) {
      var str = url.substr(1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {	
         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); //unescape( ) 对不是英文字母进行解码
      }
      theRequest['arttypeId'];   // arttypeId即得到所需参数
   }
}

你可能感兴趣的:(Job)