当前位置:网站首页>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
边栏推荐
- linux上启动oracle服务
- Compile, connect -- Notes
- The principle and common methods of multithreading and the difference between thread and runnable
- PS add texture to picture
- Homewbrew installation, common commands and installation path
- utils. Deprecated in35 may be cancelled due to upgrade. What should I do
- 第十天 异常机制
- Spark 算子之groupBy使用
- Es common query, sorting and aggregation statements
- 运维流程有多重要,听说一年能省下200万?
猜你喜欢
捡起MATLAB的第(9)天
捡起MATLAB的第(4)天
Spark 算子之groupBy使用
Construction of esp32 compilation environment
5分钟,把你的Excel变成在线数据库,神奇的魔方网表excel数据库
volatile的含义以及用法
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
Implement default page
新动态:SmartMesh和MeshBox的合作新动向
Meaning and usage of volatile
随机推荐
VIM specifies the line comment and reconciliation comment
C language --- string + memory function
Tencent offer has been taken. Don't miss the 99 algorithm high-frequency interview questions. 80% of them are lost in the algorithm
CVPR 2022 quality paper sharing
Cloudy data flow? Disaster recovery on cloud? Last value content sharing years ago
How important is the operation and maintenance process? I heard it can save 2 million a year?
299. Number guessing game
Website pressure measurement tools Apache AB, webbench, Apache jemeter
MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问
Upgrade MySQL 5.1 to 5.610
Groupby use of spark operator
Go language slice, range, set
Sort by character occurrence frequency 451
shell_ two
捡起MATLAB的第(7)天
力扣-746.使用最小花费爬楼梯
Spark 算子之sortBy使用
Homewbrew installation, common commands and installation path
How to conduct application security test (AST)
捡起MATLAB的第(9)天