009 使用servlet API作为参数
2024-08-30 03:22:56
1.哪些可以使用
MVC中的Handler方法可以接受ServletAPI类型的参数。
2.controller
package com.spring.it; import java.io.IOException;
import java.io.Writer; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class ServletApiControl {
@RequestMapping("/helloworld6")
public void hello(HttpServletRequest request,HttpServletResponse response,Writer out) throws Exception {
System.out.println("request="+request);
System.out.println("response="+response);
out.write("Spring mvc");
}
}
3.index
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<br>
<a href="helloworld6/">test servlet API</a>
</body>
</html>
4.效果
5.ps
Writer的由来
response.getWriter();
最新文章
- [转载]深入理解HTTP Session
- div模拟table,可实现左右高度同增长(html布局)
- PHP语法基础
- PHP的PSR系列规范都有啥内容
- Web安全之点击劫持(ClickJacking)
- Oracle窗口函数显示想要的行数
- poj3709
- 取PE文件的引入表和导出表
- [ERROR] Fatal error: Can&#39;t open and lock privilege tables: Table &#39;mysql.user&#39; doesn&#39;t exist 160913 02:11:21 mysqld_safe mysqld from pid file /tmp/mysql.pid ended
- MTK如何烧录IMEI码(俗称串号)
- [目录]搭建一个简单的WebGIS应用程序
- ⌈洛谷4735⌋⌈BZOJ3261⌋最大异或和【可持久化01Trie】
- 使用GeoServer导出地图数据GeoJSON并应用
- HDU 4825 Xor Sum (模板题)【01字典树】
- 利用docker搭建ubuntu+nginx+PHP容器
- Scrapy实战篇(五)之爬取历史天气数据
- 选择困难症的福音——团队Scrum冲刺阶段-Day5(补发 那天csshow)
- BZOJ1468Tree——点分治
- js fetch api
- linux系统下pdf操作软件pdftk