Molla Seleziona tag in jsp tag personalizzato
-
14-11-2019 - |
Domanda
Sto cercando di realizzare quanto segue in un tag JSP:
Seleziona.tag
<%@ attribute name="id" required="true" %>
<%@ attribute name="path" required="true" %>
<%@ attribute name="items" required="true" %>
<%@ attribute name="itemLabel" required="false" %>
<%@ attribute name="itemValue" required="false" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<form:select path="${path}" id="${id}">
<form:options items="${items}" itemLabel="${itemLabel}" itemValue="${itemValue}"/>
</form:select>
.
Utilizzo: (MycollectionAttribute è definito con @modelattribute ("mycollectionAttribute"))
<tags:select items="${mycollectionattribute}" id="id" path="mybean.selectvalue" itemLabel="label" itemValue="id"/>
.
Tuttavia, non riesco a capire come mappare correttamente la raccolta di elementi dalla pagina chiamante a questo tag.EL non sembra essere valutato e inviato come una stringa, causando il seguente errore:
javax.servlet.ServletException: Type [java.lang.String] is not valid for option items
.
Sto usando una versione piuttosto vecchia di JSTL, quella in bundle con JBoss 4.04GA, potrebbe essere il problema?Non sono sicuro che quando El Expressions vengono valutate esattamente, $ {X} direttamente in Markup non valuta ad esempio, funziona solo in tag speciali.Un aggiornamento potrebbe risolvere questo problema?E se è così, quanto è difficile usare il tuo jstl lib al posto di quello in bundle con JBoss?
Soluzione
Solved.
Was using mismatching servlet versions (2.5 specified, but JBoss 4 uses 2.4), both as dependency and in in web.xml. So EL wasn't working like it should.