❶ jsp有哪些内置对象作用分别是什么
jsp的内置对象有九个,分别如下:
pageContext javax.servlet.jsp.PageContext
request javax.servlet.http.HttpServletRequest
response javax.servlet.http.HttpServletResponse
session javax.servlet.http.HttpSession
application javax.servlet.Servlet Context –>可用this.getServletContext()替代
config javax.servlet.ServletConfig
exception java.lang.Throwable
page java.lang.Object
out javax.servlet.jsp.JspWriter
作用如下:
1、pageContext 表示页容器 –>EL、标签、上传
2、request 服务器端取得客户端的信息:头信息、Cookie、请求参数、MVC设计模式
3、response 服务器端回应给客户端信息:Cookie、重定向
4、session 表示每一个用户,用于登录验证上
5、application 表示整个服务器,getRealPath()
6、config 去的初始化参数,初始化参数在web.xml中配置
7、exception 表示的是错误页的处理操作
8、page 如同this一样,表示整个JSP页面
9、out 输出,但是尽量使用表达式输出
❷ jsp中的checkbox怎么将选中的值传到后台
前台代码应该是
<input name="checkboxname" type="checkbox" id="checkbox1" value="苹果" />苹果
<input name="checkboxname" type="checkbox" id="checkbox2" value="香蕉" />香蕉
<input name="checkboxname" type="checkbox" id="checkbox3" value="橘子" />橘子
后台获取代码是回
response.setCharacterEncoding("UTF-8");
答request.setCharacterEncoding("UTF-8");
String [] shuigou=request.getParameterValues("checkboxname");
for (int i = 0; i < shuigou.length; i++) {
String shuiguoname=shuigou[i];
System.out.println(shuiguoname);
}