El with typical arraylist return type and parameter

I want to return ArrayList<HashMap<String,String>>String with three arguments to an EL function. How to do it?

+3
source share
2 answers

In fact, I find it quite reasonable for the EL function to return some complex object. Of course, there are problems with the "architectural style" that may dictate what would and would not be suitable situations for such a thing, but I would say that some means to return some types of configuration information that is not is specific to any particular action, and not really interesting for the logic of business logic, and is likely to be useful for presentation purposes on many pages.

EL, "Object", , , "Object []". Java EL ( .tld , ), , EL . , - :

public static Object yourFunction(String arg1, String arg2, String arg3) {
    // code code code
    return (ArrayList<HashMap<String, String>>) whatever;
}

.tld - :

<function>
  <description>Blah blah blah</description>
  <name>yourFunction</name>
  <function-class>your.package.YourClassName</function-class>
  <function-signature>
    java.lang.Object yourFunction(java.lang.String, java.lang.String, java.lang.String)
  </function-signature>
</function>

JSP , :

<c:set var='result' value='${prefix:yourFunction("Goodbye", "Mr.", "Chips")}'/>
+3

tld. . :

public static List<Map<String, String>> func(String arg1, String arg2,
        String arg3) {

    List<Map<String, String>> out = new ArrayList<HashMap<String, String>>();
    // code code code
    return out;
}

.tld :

<function>
  <description>Blah blah blah</description>
  <name>func</name>
  <function-class>your.package.YourClassName</function-class>
  <function-signature>
    java.util.List&lt;java.util.Map&lt;java.lang.String,java.lang.String&gt;&gt; func(java.lang.String,java.lang.String,java.lang.String)
  </function-signature>
</function>

. , XML. . , Map<String,String>, . (, .) .

+5

Source: https://habr.com/ru/post/1733763/


All Articles