• spring mvc获取request HttpServletRequest


    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

  • 相关阅读:
    Linux网卡上添加多个IP
    TCP_Wrappers基础知识介绍
    工作、生活、思考、人生、经验、总结
    网络层安全
    centos7.0 安装nginx
    linux 下配置jdk
    yii2.0 中的队列
    centos7.0 activemq的安装
    solrCloud
    线性顺序表
  • 原文地址:https://www.cnblogs.com/zhao1949/p/4844278.html
Copyright © 2020-2023  润新知