久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

jsp學習之scriptlet的使用方法詳解

瀏覽:237日期:2022-06-08 09:53:04

scriptlet的使用

  • jsp頁面中分三種scriptlet:
  • 第一種:<% %> 可以在里面寫java的代碼。定義java變量以及書寫java語句。
  • 第二種:<%! %> 可以在里面定義全局變量以及方法,類。
  • 第三種:<%=%> 用于打印變量或者輸出值。

<% %>的使用

<html>
<head>
<title>this is java page</title>
</head>
<body>
<!--顯示注釋  注釋內(nèi)容 -->

<% 
 
int x=10;
int y=20;
String str=request.getParameter("info");
out.println("<h1>"+str+"</h1>");
out.println("<h1>"+(x+1)+"</h1>");
out.println("<h2>"+y+"</h2>");

%>

</body>

</html>

<%! %>的使用

<html>
<head>
<title>this is java page</title>
</head>
<body>
<!--顯示注釋  注釋內(nèi)容 -->

<%!
 public static final int x=10;

%>
<%!
 public int add(int x,int y)
 {
   return x+y;
 }
%>

<%!
class person
{
 private String name;
 private int age;
 public person(String name,int age)
 {
  this.name=name;
  this.age=age;
  }

  public String toString()
 {
  return "name="+name+",age="+age;
  }

}


%>
<%!
public int li=20;

%>
<%
  person p=new person("test",10);
  out.println(p);
  out.println(li);
  out.println(add(x,20));
%>
<%
 int b=10;
 out.println(b);
%>
</body>

</html>

<%= %>的使用

<html>
<head>
<title>this is java page</title>
</head>
<body>
<!--顯示注釋  注釋內(nèi)容 -->

<% 
 
int x=10;
int y=20;
String str=request.getParameter("info");

%>
<%=x%>
<%=y%>
<%="strinsssa"%>
</body>

</html>

到此這篇關(guān)于jsp學習之scriptlet的使用方法詳解的文章就介紹到這了,更多相關(guān)jsp scriptlet 內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標簽: JSP
相關(guān)文章:
主站蜘蛛池模板: 西青区| 宾阳县| 阿克陶县| 桃江县| 准格尔旗| 宜都市| 奉贤区| 乳山市| 广饶县| 沭阳县| 青冈县| 晋中市| 富源县| 象州县| 思茅市| 临桂县| 始兴县| 安宁市| 都昌县| 昌江| 平山县| 朝阳市| 织金县| 汝南县| 洛扎县| 三亚市| 崇阳县| 集安市| 壤塘县| 崇左市| 枞阳县| 武清区| 怀集县| 手游| 昌宁县| 崇文区| 灌云县| 高清| 开封县| 麦盖提县| 外汇|