English 中文(简体)
A. 如何获得物体和在共同财产制度中援引一种方法
原标题:how to get an object and invoke a method in jstl EL in a JSP
  • 时间:2010-10-05 03:51:58
  •  标签:
  • jsp
  • el

我试图将以下文字编码转换为EL。 我尝试了如下(下文),但可以让它工作。 a. 体积:

在一位听众中,我把会议称为

在我的文稿中,有:

<% 
  ConfigFactory cf = (ConfigFactory) application.getAttribute("ConfigFactory");
%>
Value from scriptlet= <%=cf.getValue()%> <br/>

EL给我带来麻烦:

<c:set var="cf" value="${initParam[ ConfigFactory ]}"/>
<c:out value="${cf.getValue}"/>  <!-- try # 1 -->
<c:out value="${cf.value}"/>     <!-- try # 2 -->
最佳回答

这一条

<c:set var="cf" value="${initParam[ ConfigFactory ]}"/>

基本不变

pageContext.setAttribute("cf", application.getInitParameter("ConfigFactory"));

你们不想这样做。 摆脱这条线。 在EL中,你仅以其名义暗中直接接触所有请求、开庭和申请属性。 以下各段:

${ConfigFactory}

基本不变

out.print(pageContext.findAttribute("ConfigFactory"));

PageContext#findAttribute(> 分别检测PageContext#getAttribute(,HttpServletRequest#getAttribute(HttpSession#getAttribute(,最后ServletContext#Attget(>,直至发现第一个非核心值为止。 这正是你们想要的。

您最终可以查阅getValue () 方法上通常采用的EL方法:

${ConfigFactory.value}

与此无关,但你通常会提供从下级开始的识别符号。 页: 1 ConfigFactory = New ConfigFactory ();, right?

问题回答

未测试:

${applicationScope.ConfigFactory.value}




相关问题
Convert typed-in Text to lowercase

I ve got an index.jsp with [snip] <% String name = request.getParameter("name"); String pass = request.getParameter("pass"); String globalname = "webeng"; String globalpass = "2009"; ...

session transfer issue from Tomcat to ASP.Net

I am using Tomcat to host JSP and using IIS 7.0 to host aspx (C# + .Net 3.5 + VSTS 2008), and I have some session transfer issue from JSP page to ASPX page. JSP page is in one domain and all other ...

Setting the default value in Struts2

I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...

Evaluate dynamically constructed JSP at runtime

I have a requirement where in the JSP page itself is created by the user and stored in the database. When viewing results we need to render this JSP to the client, evaluating all tags inside this JSP. ...

How to Pack/Encrypt/Unpack/Decrypt a bunch of files in Java?

I m essentially trying to do the following on a Java/JSP-driven web site: User supplies a password Password is used to build a strongly-encrypted archive file (zip, or anything else) containing a ...

JSP exception - class not found (tomcat)

I m setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root ...

ArrayList to Table in JSP

I have an ArrayList and i am trying to display it in a table ..... ArrayList rows = .... ..... <table cellspacing="1" cellpadding="4" border="3"> <tr> <TH>...

热门标签