JSP 标记文件和库如何工作?
我一直在学习 JSP 并遇到过标记文件和库。我知道它们是自定义操作,对于指出错误很有用,而不是使用 JavaBean,但我仍然不明白它们是如何工作的。假设您这样做:
<jsp:directive.attribute name = "amount" required = "true" />
然后,假设使用 jsp:useBean
定义 calc
,则可以使用 amount
:
<c:set target="${calc}" property = "amount" value ="${amount}" />
但是会发生什么幕后?
I've been learning about JSPs and came across tag files and libraries. I know that they are custom actions and useful for pointing out errors instead of using JavaBeans for example, but I still don't understand how they work. Lets say for example you do:
<jsp:directive.attribute name = "amount" required = "true" />
And later, assuming that calc
is defined using jsp:useBean
, amount
can be used by:
<c:set target="${calc}" property = "amount" value ="${amount}" />
But what happens behind the scenes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标记文件是用 JSP 编写的自定义标记处理程序。这些 jsp 由 JSP 编译器转换为 java 标记处理程序。
Tag files are custom tag handlers which are written in JSP. These jsp are converted to java tag handlers by the JSP compiler.
${calc}
表示变量calc
的值,该变量可能存在于 pageCOntext、request、session、Servletcontext 中,通过该语句,
它将在
calc
var 的amount
由 value 表示,在幕后它会是
${calc}
represents value of variablecalc
which may be there in pageCOntext,request,session,ServletcontextBy the statement
it will store value in
calc
var'samount
represented by valueBehind the scene it would be