Is it possible to use Tiles inside SpringMVC tags?

1

Hello, I'm creating a generic form so that I can parameterize some attributes. I want to do the following:

<sf:form cssClass="form" modelAttribute="<tiles:getAsString name="modelAttribute"/>" action="<tiles:getAsString name="action"/>" />

When I do this however, when I load the screen I get the following exception:

org.apache.jasper.JasperException: /forma-page.jsp (line: 4, column: 81) equal symbol expected

When I do not use the specific spring tag, the code works. I would like to use this way to be able to validate using BeanValidation.

    
asked by anonymous 12.11.2015 / 02:35

1 answer

1

Can not do this.

Of course we sometimes mix a JSP tag with an HTML tag, but you can not put a JSP tag inside another JSP tag.

One way to resolve this is to make template attributes available as attributes within the JSP and then use them normally in the Spring taglib or any other.

An example of how to do this ( from the documentation ):

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles-extras" prefix="tilesx" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<tilesx:useAttribute id="list" name="items" classname="java.util.List" />
<c:forEach var="item" items="${list}">
  ...
</c:forEach>

In the above example, the tilesx:useAttribute tag causes the items attribute to be made available in the JSP scope as list . The list is then used in the loop using expression language .

    
12.11.2015 / 05:23