当前位置:网站首页>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
边栏推荐
- VIM uses vundle to install the code completion plug-in (youcompleteme)
- Win11 / 10 home edition disables the edge's private browsing function
- Vision of building interstellar computing network
- Spark 算子之partitionBy
- js正则判断域名或者IP的端口路径是否正确
- 腾讯Offer已拿,这99道算法高频面试题别漏了,80%都败在算法上
- Jour (9) de ramassage de MATLAB
- How do you think the fund is REITs? Is it safe to buy the fund through the bank
- Named in pytoch_ parameters、named_ children、named_ Modules function
- PS为图片添加纹理
猜你喜欢
TIA博图——基本操作
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
volatile的含义以及用法
Function summary of drawing object arrangement in R language
一文读懂串口及各种电平信号含义
【现代电子装联期末复习要点】
Method 2 of drawing ROC curve in R language: proc package
捡起MATLAB的第(4)天
捡起MATLAB的第(8)天
随机推荐
Leetcode-374 guess the size of the number
New developments: new trends in cooperation between smartmesh and meshbox
What is the experience of using prophet, an open source research tool?
王启亨谈Web3.0与价值互联网“通证交换”
捡起MATLAB的第(7)天
dlopen/dlsym/dlclose的简单用法
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
捡起MATLAB的第(6)天
建设星际计算网络的愿景
捡起MATLAB的第(4)天
js正则判断域名或者IP的端口路径是否正确
安装Redis并部署Redis高可用集群
Application case of GPS Beidou high precision satellite time synchronization system
Six scenarios of cloud migration
Go language slice, range, set
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
Cloud migration practice in the financial industry Ping An financial cloud integrates hypermotion cloud migration solution to provide migration services for customers in the financial industry
Countdown 1 day ~ 2022 online conference of cloud disaster tolerance products is about to begin
贫困的无网地区怎么有钱建设网络?
Function summary of drawing object arrangement in R language