问题描述
我正在构建自己的JSP标记库,该库需要支持应用程序开发人员可以使用的某些功能,如下所示:
I'm building my own JSP Tag Library which need to support some features that Application developers can use like this:
<w:user-label id="usrlb" value="${session.user}"/>
<w:textbox id="tb" label="User Name" value="${usrlb.value.name}"/>
这意味着我希望我的EL可以与我的Tag声明进行交互.而且我还需要在该库中添加堆栈概念以支持"id名称空间"之类的东西.
which means I want my EL can interact with my Tag declaration. and also I need to add stack concept into this library to support "id namespace" or something.
我目前的研究使我像这样包装默认的JspFactory:
My current research leads me to wrap default JspFactory like this:
JspFactory.setDefaultFactory(new JspFactoryImpl(JspFactory.getDefaultFactory()));
哪一个可以在Tomcat5.5中工作,但这不是一个好主意.还有其他更漂亮的方法吗?
Which could work in Tomcat5.5 although it's not a good idea.Is there any other more pretty way to do that?
推荐答案
您可以让您的<w:user-label />
标记类仅向上下文的范围之一(请求,会话等)添加变量,以便EL表达式可以找到它?如果添加到范围中的bean遵循JavaBeans约定,则嵌套属性应使用EL可用.
You could have your <w:user-label />
tag class simply add a variable to one of the context' scopes (request, session, ...) so EL expressions can find it? If the bean you add to the scope follows JavaBeans conventions, nested properties should be available using EL.
这篇关于如何在Jsp 2.0中将自定义VariableResolver添加到JSP上下文中以支持特殊EL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!