". Specified information can also be output anywhere on the page."/> ". Specified information can also be output anywhere on the page.">

Home >Java >javaTutorial >What does the syntax of expressions in jsp begin with?

What does the syntax of expressions in jsp begin with?

(*-*)浩
(*-*)浩Original
2019-05-20 15:48:454035browse

JSP expression is used to output information to the page. Its syntax format is as follows:

What does the syntax of expressions in jsp begin with?

##<%= Expression%>, Starts with "<%=" and ends with "%>"

Parameter description:

Expression: It can be a complete expression of any Java voice. The final result of the expression will be converted to a string.

Here are some simple examples:

<%@ page language="java" import="java.util.*"
	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>测试JSP表达式的使用</title>
</head>
<body>
 
	<!-- 输出变量 -->
	<%
	    String manager = "小李";
	%>
	管理员:<%=manager%>
	<%="管理员:" + manager%>
 
	<!-- 输出表达式计算结果 -->
	<%=1 + 2%>
 
	<!-- 执行Java代码 -->
	<%
	    int x = 10;
	    out.println(x);
	%>
 
	<!--  将表达式插入到HTML标记中-->
	<%
	    String url = "test.png";
	%>
	<img src="images/<%=url%>" />
 
	<br>
	<!-- 输出系统时间 -->
	<%=new Date()%>
 
	<!-- 执行多个片断 -->
	<%
	    for (int i = 0; i < 5; i++) {
	%>
 
	<H2>http://blog.csdn.net/u010142437</H2>
 
	<%
	    }
	%>
 
 
</body>
</html>
Related learning recommendations:

java basic tutorial

The above is the detailed content of What does the syntax of expressions in jsp begin with?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn