JSTL or JSP 2.0 EL for getter with argument

How can I access a recipient that has a parameter using JSTL or JSP 2.0 EL?

I want to access something like this:

public FieldInfo getFieldInfo(String fieldName) { .... } 

I could access this in Struts using the mapped properties , but I don't know if this is possible in JSTL or JSP 2.0.

I tried everything but did not work.

+8
java properties jsp jstl
source share
1 answer

Transmission Method Arguments in EL - This is only the EL specification supported in EL 2.2. EL 2.2 is shipped by default in Servlet 3.0 / JSP 2.2 containers. Therefore, if you use the Servlet 3.0 container (Tomcat 7, Glassfish 3, JBoss 6, etc.), and your web.xml declared compatible with the Servlet 3.0 spec, then you should have access to it as follows

 ${bean.getFieldInfo('fieldName')} 

Since you explicitly mentioned JSP 2.0, which is part of the old Servlet 2.4 specification, I assume there is no room for updating. It’s best to replace the method with

 public Map<String, FieldInfo> getFieldInfo() { // ... } 

so that you can access it as follows

 ${bean.fieldInfo.fieldName} 

or

 ${bean.fieldInfo['fieldName']} 

or

 ${bean.fieldInfo[otherBean.fieldName]} 
+22
source share

All Articles