您的位置:首页 > 理论基础 > 计算机网络

spring mvc获取request HttpServletRequest

2015-09-28 16:14 585 查看
1.最简单的方式(注解法)

2. 直接的方法,参数中添加(response类似)

package spittr.web;

import static org.springframework.web.bind.annotation.RequestMethod.*;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;

@Controller
@RequestMapping("/")
public class HomeController {

//@Autowired    //方法1
//private HttpServletRequest req;

@RequestMapping(method = GET)
// public String home(Model model) { //方法2
public String home(Model model, HttpServletRequest req) {
System.out.println(req.getParameter("x"));
return "home";
}

}


 

=======================

参: http://www.cnblogs.com/xusir/p/4135419.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring mvc