<%有什么区别! %> <%%>在JSP中? [英] What is the difference between <%! %> and <% %> in JSP?

查看:175
本文介绍了<%有什么区别! %> <%%>在JSP中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSP中的<%! %><% %>有什么区别?

What is the difference between <%! %> and <% %> in JSP?

推荐答案

<%! %> JSP声明标记,而<% %> JSP脚本标签.

您在scriptlet中放入的任何代码在编译时都将放入JSPs _jspService()方法中(类似于Servlet的doGetdoPost,...方法).这就是您通常用Java代码编写的内容.

Any code you put in scriptlets gets put in the JSPs _jspService() method when it's compiled (the analogue of a Servlet's doGet, doPost,... methods). This is what you'd usually write your Java code in.

但是,如果您想在JSP类中声明新方法或声明实例变量怎么办?那就是您要使用声明标签的时候.您在其中放置的任何内容都会放入JSP中,即_jspService()方法的外部.

But what if you want to declare new methods in your JSP class or declare instance variables? That's when you'd use the declaration tags. Any thing you put in there gets put into the JSP, outside of the _jspService() method.

这篇关于&lt;%有什么区别! %&gt; &lt;%%&gt;在JSP中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆