❶ 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);
}