[英]Rendering CSS file from String variable.
Is it possible to render a css file from a string data that i found from my controller class? 是否可以根据我从控制器类中找到的字符串数据来呈现CSS文件? I have a jsp page, and the page will try to get a css varilable like this: 我有一个jsp页面,并且该页面将尝试获取如下的CSS变量:
<link rel="stylesheet" type="text/css" href="/Style/css=${css}" />
Style is the method on the controller class that returns css string variable. 样式是控制器类上返回css字符串变量的方法。 Simply the Style method returns a string. 只需使用Style方法即可返回一个字符串。 I have it on jsp. 我在jsp上有它。 But i couldn't render it as a css file, it just returns it on the page. 但是我无法将其呈现为CSS文件,它只是在页面上将其返回。 Is there any way to render that string as a css file. 有什么方法可以将该字符串呈现为css文件。
Nope, you can't do that. 不,你不能那样做。 Easiet solution: 简便的解决方案:
<style type="text/css"> ${css} </style>
Otherwise you have to create new file with contents of ${css}
variable and than include it in html with <link>
tag. 否则,您必须使用${css}
变量的内容创建新文件,然后使用<link>
标记将其包含在html中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.