日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[转载] jstl获取Parameter参数及switch使用

發布時間:2025/3/11 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [转载] jstl获取Parameter参数及switch使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考鏈接: Java中的字符串使用switch

<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>??

??

param 獲取 Parameter參數 <c:choose>? ? ? ?<c:when test="${empty param.name}">? ? ? ? ? Please enter your name.? ? ? </c:when>? ? ? ? ? ? ? <c:otherwise>? ? ? ? ? Hello <b><c:out value="${param.name}" /></b>!? ? ? </c:otherwise>? </c:choose>?

??

一般而言,我們在取得用戶的請求參數時,可以利用下列方法: request.getParameter(String name) request.getParameterValues(String name) 在EL中則可以使用param和paramValues兩者來取得數據。 ${param.name} ${paramValues.name}可以取得所有同名參數的值 ${paramValues.hobbies[0]}可以通過指定下標來訪問特定的參數的值?

??

獲取訪問路徑?

${pageContext.request.contextPath}?

等同于??

?<%=request.getContextPath()%>?

??

獲取Session?

${sessionScope.user.sex}?

? ? ? 上述EL范例的意思是:從Session取得用戶的性別。?

? ? ? ?如果使用之前JSP代碼的寫法如下: <% User user = (User)session.getAttribute(”user”); String sex = user.getSex( ); %>?

??

EL的隱含對象?

EL也可以使用內置對象中設置的屬性,需要使用特定的EL內置對象?

屬性范圍? ? ?|? ? 在EL中的對象?

Page? ? ? ? ?|? ? ?pageScope?

Request? ? ? |? ? ?requestScope?

Session? ? ? |? ? ?sessionScope?

Application |? ? ?applicationScope?

?

?EL中使用內置對象的屬性 ${requestScope.user} 等價于 <%request.getAttribute(”user”)%> 如果不寫出特定的范圍 ,那就會在不同的范圍間進行搜索了 例:{user}(user是在request范圍 request.setAttribute(”user”,user)) 也就等于 ${requestScope.user} <%request.getAttribute(”user”)%>?

?pageContext對象 我們可以使用 ${pageContext}來取得其他有關用戶要求或頁面的詳細信息。下面列出了幾個比較常用的部分。 Expression? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 說 明 ${pageContext.request}? ? ? ? ? ? ? ? ? |取得請求對象 ${pageContext.session}? ? ? ? ? ? ? ? ? |取得session對象 ${pageContext.request.queryString}? ? ? |取得請求的參數字符串 ${pageContext.request.requestURL}? ? ? ?|取得請求的URL,但不包括請求之參數字符串 ${pageContext.request.contextPath}? ? ? |服務的web application的名稱 ${pageContext.request.method}? ? ? ? ? ?|取得HTTP的方法(GET、POST) ${pageContext.request.protocol}? ? ? ? ?|取得使用的協議(HTTP/1.1、HTTP/1.0) ${pageContext.request.remoteUser}? ? ? ?|取得用戶名稱 ${pageContext.request.remoteAddr }? ? ? |取得用戶的IP地址 ${pageContext.session.new}? ? ? ? ? ? ? |判斷session是否為新的,所謂新的session,表示剛由server產生而client尚未使用 ${pageContext.session.id}? ? ? ? ? ? ? ?|取得session的ID ${pageContext.servletContext.serverInfo}|取得主機端的服務信息

總結

以上是生活随笔為你收集整理的[转载] jstl获取Parameter参数及switch使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。