JSP Basic Syntax
First, comments
1. Explicit annotations, client-visible
<!-- Comment -
2. implicit annotation, client not visible
// Comment Line
/* Comment Multiple lines * /
<%--jsp Comment -
Second, Scriptlet
1. the first type of scriptlet: <%%>
Can be used to define local variables , write statements, etc.
<% int x = 10; String info = "www.126.com"; Out.println ("2. the second type of scriptlet: <%!%>
You can define global variables, methods, classes
<%! public static finalString INFO = "Www.126.com"; int x = 10;%><%! public int add (int x,int y) { return x+y; }% ><%! class person{ private Stringname; private int age; publicperson (string name, int age) { this.name = name; this.age = age; } Public stringtostring () { return "name=" + this.name + "; age=" &Nbsp;+ this.age; } }%><% out.println ("3. the third type of scriptlet: <%=%>, also known as an expression output
The main function is to output a variable or a specific constant
<% String info = "www.126.com"; int temp = 30;%><%--uses an expression to output variables and constants--%>
Output is typically output with an expression without out.println ()
Example 1:
Example 2 slightly
Third, Scriptlet label
Provide <jsp:script></jsp:script>, same as <%%> function
<jsp:script>
Java Scriptelet Code
</jsp:scipt>
The above content reference Javaweb development actual combat Classics (teacher pulpit)
This article is from the "Beyond the Horizon" blog, be sure to keep this source http://udbful.blog.51cto.com/10601869/1683013
01_01 JSP Basic syntax