How to use a tile variable in Jsp page

2019-02-27 03:16发布

问题:

I have a variable defined in tiles. I want to use that variable in JSP page. I tried using

<tiles:put name="title"><tiles:getAsString name="title" /></tiles:put> 

but i am not able to assign the value in some var in jsp page. Depending on the variable i need to implement some logic in jsp page. How to do this?

回答1:

Use some definition in tiles-defs.xml:

<definition name="title.tile" >
    <put-attribute name="title" value="Some Title" type="string"/>
</definition>

Now in the tile you can use

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
<title><tiles:getAsString name="title" /></title>


标签: jsp struts tiles