我们有一个系统为不同大小的页面使用多个装饰器,同时使用相同的内容页面。 我试图设置一个可以传递给内容页面(用JSP编写)的变量。 例如
<c:set var="pagetype" value="mobile/" />此方法不起作用,因为内容页面被发送到装饰器,因此需要首先生成。 有没有一种方法可以在编译之前将一个变量传递到页面中,以便例如我可以在不同装饰器的不同文件夹中使用响应式图像(例如
<img src="uploads/${pagetype}/img.jpg />We have a system which uses multiple decorators for different sized pages, whilst using the same content pages. I'm trying to set a variable which can be passed to the content pages (which are written in JSP). e.g.
<c:set var="pagetype" value="mobile/" />This method does not work because the content pages are sent to the decorator and thus need to be generated first. Is there a way to pass a variable into the pages before they are compiled, so that for instance I can use responsive images in different folders with different decorators (e.g.
<img src="uploads/${pagetype}/img.jpg />最满意答案
解决方案是将其添加到请求范围:
<c:set var="pagetype" value="mobile/" scope="request" />Solution is to add it to the request scope:
<c:set var="pagetype" value="mobile/" scope="request" />更多推荐
pages,页面,content,电脑培训,计算机培训,IT培训"/> <meta name="description&
发布评论