Servlet学习笔记
时间:2016-03-30 22:18:45
收藏:0
阅读:206
Servlet开发步骤
- 继承HttpServlet
- 重写doGet和doPost方法
- 在web.xml注册servlet(servlet3.0中不需要注册,,选择新建servlet时,系统自动直接使用@webservlet注解)

重写doGet()与doPost()注意事项
super.doGet(req, resp);
需注释掉(这是调用了父类的方法)
- 使用
PrintWriter
时,需用resp.setContentType("text/html;charset=utf-8");
//设置显示方式及编码
Servlet与JSP九大内置对象

super.doGet(req, resp);
需注释掉(这是调用了父类的方法)PrintWriter
时,需用resp.setContentType("text/html;charset=utf-8");
//设置显示方式及编码JSP对象 | Servlet中怎样获得 |
---|---|
out | resp.getWriter |
request | req参数 |
response | resp参数 |
session | req.getSession()函数 |
application | getServletContext()函数 |
exception | Throwable |
page | this |
pageContext | pageContext |
Config | getServletConfig()函数 |
Java后台处理form表单提交的复选框数据(字符串数组)
String[] favorites;
favorites = request.getParameterValues("favorite");
原文:http://www.cnblogs.com/Val1ant/p/5338900.html
评论(0)