JSP中的注释操作及JSP中的三种Scriptlet
2016-01-27 14:19
597 查看
[b]***JSP中的注释操作及JSP中的三种Scriptlet********[/b]
1,JSP中的注释操作
<h3><1>显示注释</h3> 语法:<!--注释内容--> 注:注释客户端是可以看见的 <h3><2>隐式注释</h3> 语法:格式一://注释,单行注释 格式二:/*注释*/,多行注释 格式三:<%--注释--%>,jsp注释
2,JSP 中的三种Scriptlet
<h3><1>用于定义局部变量</h3> 格式:<%%> 例子: <% int x=10; String info="www.baidu.com"; out.print("<h2>x="+x+"</h2>"); out.print("<h2>info="+info+"</h2>"); %> <h3><1>用于定义全局变量、方法、类</h3> 格式:<%!%> 例子: <%! public static final String info="www.baidu.com";//定义全局变量 %> <%! class Person{ private String name; private int age; public Person(String name,int age){ this.name=name; this.age=age; } public String toString(){ //覆写toString方法 return "name="+this.name+"age="+this.age; } } %> <%! public int add(int x,int y){ return x+y; } %> <% //编写普通的Scriptlet out.print("<h3>info="+info+"</h3>"); out.print("<h3>3+5="+add(3,5)+"</h3>"); out.print("<h3>"+new Person("张三",15)+"</h3>"); %> <h3><1>用于输入一个变量或一个具体内容</h3> 格式:<%=%> 例子: <% String info="www.baidu.com"; int temp=30; %> <h2><%=info%></h2> <h2><%=temp%></h2>
相关文章推荐
- ConvNetJS源代码解析第二篇
- js页面跳转整理
- js入门——Dom基础
- 服务端嵌套json
- erlang 用rfc4627 带中文的json格式
- JS操作JSON总结
- js标签放在html的什么位置比较好
- 用window.onerror捕获并上报Js错误的方法
- js存cookie
- String与JSON的转换和Array转String
- javascript下的瀑布流效果
- 再谈JavaScript异步编程
- c标签 if else c标签 总结
- ClickSpark.js实现粒子特效
- 简单介绍jsonp 使用小结
- 理解javascript异步编程
- QT和JavaScript互调
- js基础总结
- js实现的鼠标滚轮滚动切换页面效果(类似360默认页面滚动切换效果)
- 原生js实现简单打字机效果