SpringMVC之获取Servlet原生API

获取Servlet的原生API挺简单的,只需要在处理请求的方法中写上对应的形参即可。

案例:

1. servletAPI.jsp

<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/6/8
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    Title


   获取Servlet的元素API


2. ServletApiController

package cn.itcast.controller;

import cn.itcast.domain.User1;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class ServletApiController {

    @RequestMapping("/testServletApi")
    public void saveAccount(HttpServletRequest request, HttpServletResponse response){
        System.out.println(request);
        System.out.println(response);
    }
}

 

你可能感兴趣的:(SpringMVC)