从Sitemesh Decorator传递一个变量(Pass a variable from Sitemesh Decorator)

编程入门 行业动态 更新时间:2024-10-28 10:31:04
从Sitemesh Decorator传递一个变量(Pass a variable from Sitemesh Decorator)

我们有一个系统为不同大小的页面使用多个装饰器,同时使用相同的内容页面。 我试图设置一个可以传递给内容页面(用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&

本文发布于:2023-08-01 07:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1354304.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   Decorator   Sitemesh   Pass   variable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!