表达式语言功能和自定义标签之间有什么区别? [英] What is the difference between expression language functions and custom tags?

查看:105
本文介绍了表达式语言功能和自定义标签之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为什么要使用自定义标签而不是el函数?比较它们的优点/缺点是什么?

解决方案

最初设计EL的目的是在JSTL标签以及您可能要使用或编写的任何其他自定义标签的属性内使用. /p>

JSP规范的更高版本允许直接在JSP内部使用EL,但这并不意味着JSTL不再有用.您可以直接在JSP中直接使用EL进行的唯一操作就是向响应中写入一些值,例如

$ {user.id} 它将写入用户Bean的ID.如果您需要测试,循环,HTML转义,URL,日期数字格式等,则仍然需要使用JSTL. EL本身不是很有用!您可以将EL与Custom标签一起使用,以帮助简化代码,特别是对于非Java程序员!在以下位置的自定义标记中使用EL: http://www.java -samples.com/showtutorial.php?tutorialid=551

Why would I go for custom tags instead of el functions? What are the advantages / disadvantages when they are compared?

解决方案

The EL, initially, has been designed to be used inside attributes of the JSTL tags, and any other custom tag you might want to use or write yourself.

A later version of the JSP spec has allowed using the EL directly inside the JSPs, but this doesn't mean the JSTL isn't useful anymore. The only thing you can do with EL directly in the JSP is to write some value to the response like for example

${user.id} which would write the ID of the user bean. If you want tests, loops, HTML escaping, URLs, date an number formatting, etc., you still need to use the JSTL. EL on itself is not very useful!you can use EL with Custom tags to help simplify your code especially for non-java programmers! Have alook on the use of EL in Custom tags here:http://www.java-samples.com/showtutorial.php?tutorialid=551

这篇关于表达式语言功能和自定义标签之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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