JSP标签

JSP标签:
    JSP标签也称之为jsp Action  元素,它用于在jsp页面中提供业务逻辑功能,避免在jsp页面中直接编写java代码,造成jsp页面难以维护
<jsp:forward> 转发
    属性page=""要转发的页面
<jsp:include> :页面的包含  
此为动态包含页面它与<% @include  file=""%> 区别,动态是把所有包含的页面都动态编译成一个.java和.class文件,而静态是 直接 先把所包含的页面内容复制 到总页面中再统一编译成一个.java和.class文件
<jsp:param>  传递参数
把数据封装到JavaBean中(jsp页面中完成)
  <jsp:useBean>
  <jsp:setProperty>
  <jsp:getProperty>
 < jsp:useBean id="user" class ="vo.user"></ jsp:useBean>
 < jsp:setProperty property ="name" name="user"/>
  < jsp:setProperty property ="password" name="user"/>
 
如果有多个属性 就可以使用 < jsp:setProperty property ="*" name="user"/>
把所有的和定义的类user类中属性名称相同的request.paramter传过来的参数都赋值到 user 中去,在下面就都可以使用了
 
 
  < jsp:getProperty property ="name" name="user" />
    <jsp:getProperty property ="password" name="user" />
 
 
 
 
 
 
<%@ page language ="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<meta http-equiv= "Content-Type" content ="text/html; charset=UTF-8">
<title> Insert title here</ title>
</head>
<body>
<h3> 转发</ h3>
<jsp:forward page= "/include/body.jsp">
<jsp:param value= "aaa" name ="name"></jsp:param>
</jsp:forward>
</body>
</html>
 
<%@ page language ="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<meta http-equiv= "Content-Type" content ="text/html; charset=UTF-8">
<title> Insert title here</ title>
</head>
<body>
<jsp:include page= "/include/head.jsp"></jsp:include >
<jsp:include page= "/include/menu.jsp"></jsp:include >
<h3> 网站主体</h3 >
<%="Hello" %>
<% out.print( "AAAA"); %>
<% response.getWriter().write( "BBB"); %>
<% out.print( "CCC"); %>
<jsp:include page= "/include/foot.jsp"></jsp:include >
<%
pageContext.setAttribute("name","美美");
pageContext.setAttribute("name", "痘痘",pageContext. PAGE_SCOPE);
 %>
 <%= request.getParameter("name" ) %>
</body>
</html>
原文地址:https://www.cnblogs.com/haofaner/p/5632101.html