java web中 EL表达式的相关案例:

发布时间:2023年12月26日

java web中 EL表达式的相关案例:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    
    <%
    String abc="ABC";
    String xyz="XYZ";
    //原因是没有把abc放到作用域里
    pageContext.setAttribute("abc", xyz);
    pageContext.setAttribute("xyz", abc);
    
    session.setAttribute("abc", "abcabcabc");
    
    request.setAttribute("aaa", "requestAAA");
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
 
${sessionScope.abc }<br>${pageScope.xyz}<br>${aaa}
<%
  //request.getRequestDispatcher("p12260.jsp").forward(request, response);
//request.getRequestDispatcher("p12260.jsp?www=www666").forward(request, response);

request.getRequestDispatcher("p12260.jsp?www=www666&www=www777").forward(request, response);
%>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
      <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
 
${sessionScope.abc }<br>${pageScope.xyz}<br>${aaa}<br>${param.www }<br>




<c:forEach items="${paramValues.www}" var="u">
Item <c:out value="${u}"/><p>
</c:forEach>

</body>
</html>

文章来源:https://blog.csdn.net/laocooon/article/details/135214843
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。