当前位置:网站首页>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
边栏推荐
- 贫困的无网地区怎么有钱建设网络?
- 451. 根据字符出现频率排序
- Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
- Construction of esp32 compilation environment
- 一文读懂串口及各种电平信号含义
- R语言中实现作图对象排列的函数总结
- C语言自编字符串处理函数——字符串分割、字符串填充等
- [self entertainment] construction notes week 2
- Day (6) of picking up matlab
- C#,贝尔数(Bell Number)的计算方法与源程序
猜你喜欢
TIA botu - basic operation
Matplotlib tutorial 05 --- operating images
Research and Practice on business system migration of a government cloud project
New developments: new trends in cooperation between smartmesh and meshbox
贫困的无网地区怎么有钱建设网络?
Using JSON server to create server requests locally
The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
GRBL学习(一)
Meaning and usage of volatile
随机推荐
Go concurrency and channel
Named in pytoch_ parameters、named_ children、named_ Modules function
Homewbrew installation, common commands and installation path
volatile的含义以及用法
Review 2021: how to help customers clear the obstacles in the last mile of going to the cloud?
捡起MATLAB的第(7)天
shell_ two
JVM - Chapter 2 - class loader subsystem
Day (8) of picking up matlab
js正則判斷域名或者IP的端口路徑是否正確
Config组件学习笔记
Compile, connect -- Notes
Implement default page
Algorithem_ ReverseLinkedList
Spark 算子之交集、并集、差集
Distinct use of spark operator
通过Feign在服务之间传递header请求头信息
Research and Practice on business system migration of a government cloud project
建设星际计算网络的愿景
Spark 算子之coalesce与repartition