当前位置:网站首页>JSP learning 3
JSP learning 3
2022-04-23 16:06:00 【If you believe】
1、jsp action
<%@ page contentType="text/html; charset=UTF-8" pageEnconding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<%--
jsp action :
Format :<jsp: denomination of dive Property name = Property value Property name = Property value ......></jsp: denomination of dive >
1、forward action
Example : Current page
<body>
handsome guy <br>
<jsp:forward page="/net.jsp"></jsp:forward>
</body>
stay net.jsp in
<body>
beauty
</body>
The result page only outputs beauty , Without outputting handsome men
2、include action
Example : Current page
<body>
handsome guy <br>
<jsp:include page="/net.jsp"></jsp:include>
<%=a%>// Will report a mistake
</body>
stay net.jsp in
<body>
beauty <br>
<%
String a="11";
%>
</body>
The result page outputs handsome men and beautiful women , And no output a
--%>
</body>
</html>
2、EL expression (1)
<%@ page contentType="text/html; charset=UTF-8" pageEnconding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<%--
EL expression : Data can only be obtained from four domains , And cannot be assigned
use ${
} You can get the value , And show it
Example 1:<body>
<%
String user="11";
%>
user=${
user}
</body>
result :user= No, user Value
Example 2:<body>
<%
String user="11";
request.setAttribute("user",user);
%>
user=${
user}
</body>
result :user=11
Example 3:<body>
<%
pageContext.setAttribute("add","11");
request.setAttribute("add","22");
session.setAttribute("add","33");
application.setAttribute("add","44");
%>
add=${
add}
// The order of query is pageContext,request,session,application
// Display after query , Refreshing the page will query the next
</body>
--%>
</body>
</html>
bean attribute
EL Of Bean attribute : First step : Create a class
package com;
public class Student{
private String name;
private int age;
public Student(){
super();
}
public Student(){
super();
this.name=name;
this.age=age;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age=age;
}
public int getAge(){
return age;
}
@Override
public String toString(){
return "Student[name="+name+",age="+age+"]";
}
}
The second step , stay jsp Use in
<%@ page contentType="text/html; charset=UTF-8" pageEnconding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title></title>
</head>
<body>
<%
Student student=new Student(" Zhang San ",25);
pageContext.setAttribute("student",student);
%>
student=${
student}<!-- Accept student All the values -->
name=${
student.name}<!-- Accept student in name Value -->
</body>
</html>
版权声明
本文为[If you believe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231404212069.html
边栏推荐
猜你喜欢
捡起MATLAB的第(6)天
Filter usage of spark operator
[key points of final review of modern electronic assembly]
matplotlib教程05---操作图像
Unity shader learning
Config learning notes component
Review 2021: how to help customers clear the obstacles in the last mile of going to the cloud?
Day (7) of picking up matlab
JVM - Chapter 2 - class loader subsystem
Day (6) of picking up matlab
随机推荐
Day (10) of picking up matlab
Coalesce and repartition of spark operators
Unity shader learning
如何进行应用安全测试(AST)
Day (2) of picking up matlab
GRBL学习(一)
Day (9) of picking up matlab
homwbrew安装、常用命令以及安装路径
Using JSON server to create server requests locally
CVPR 2022 quality paper sharing
【开源工具分享】单片机调试助手(示波/改值/日志) - LinkScope
Day (8) of picking up matlab
C, calculation method and source program of bell number
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Filter usage of spark operator
js正则判断域名或者IP的端口路径是否正确
Spark 算子之交集、并集、差集
运维流程有多重要,听说一年能省下200万?
New developments: new trends in cooperation between smartmesh and meshbox
新动态:SmartMesh和MeshBox的合作新动向