这与我的previous question有些关系,我可以通过这种方式显示图像从属性文件中获取其URL:
<img height="40" src="<s:text name="login.logo"/>" class="pagelogo" alt="Logo" /> Login
使用相同的方式我可以编辑某些style
/ CSS属性:
<h2 class="ccsBlockTitle" style="background-color: <s:text name="welcome.color" />">Welcome<h2>
我的content.properties
看起来像这样:
login.logo=/oneFolderBefore/resources/media/login.png
login.title=Login
welcome.color=red
gui.theme=blitzer
Here是可用主题的列表,how to use them
但是以这种方式调用它时:
<sj:head locale="es" jqueryui="true" jquerytheme="<s:text name="gui.theme"/>" compressed="false" defaultIndicator="ajax_loading" />
我希望上面的代码能够“减少”/“翻译”为:
<sj:head locale="es" jqueryui="true" jquerytheme="blitzer" compressed="false" defaultIndicator="ajax_loading" />
然而,我得到的是像这样的错误:
java.lang.RuntimeException: org.apache.jasper.JasperException: /WEB-INF/decorators/PlantillaWeb.jsp (line: [37], column: [73]) equal symbol expected
com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:39)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84)
org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:164)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:372)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:276)
com.seguritech.botones.plugin.interceptor.ValidarSesionInterceptor.intercept(ValidarSesionInterceptor.java:51)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieProviderInterceptor.intercept(CookieProviderInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieInterceptor.intercept(CookieInterceptor.java:258)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CookieInterceptor.intercept(CookieInterceptor.java:258)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:575)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
第37行是上面发布的,第73行是me
中的gui.theme
。
所以,我想改变单引号的内部双引号:
<sj:head locale="es" jqueryui="true" jquerytheme="<s:text name='gui.theme'/>" compressed="false" defaultIndicator="ajax_loading" />
但是当我检查我的HTML时,我得到了这个:
<link id="jquery_theme_link" rel="stylesheet" href="/my-project/struts/themes/<s:text name='gui.theme'/>/jquery-ui.css?s2j=3.7.1" type="text/css">
如果我像这样更改外部的那些:
<sj:head locale="es" jqueryui="true" jquerytheme='<s:text name="gui.theme"/>' compressed="false" defaultIndicator="ajax_loading" />
我明白了:
<link id="jquery_theme_link" rel="stylesheet" href="/my-project/struts/themes/<s:text name=" gui.theme"="">
我也尝试更改jquerytheme
${gui.theme}
的值,但我遇到了与上一个问题相同的错误:
根据标记文件中的TLD或属性指令,属性值不接受任何表达式
那么,更改从jquerytheme
文件中检索它的content.properties
属性值的另一种方法是什么?
在上述情况中,除了第一个(使用双引号),我得到了默认的base
主题。
答案 0 :(得分:1)
我结束了这条线:
<sj:head locale="es" jqueryui="true" jquerytheme="base" compressed="false" defaultIndicator="ajax_loading" />
后来我在阅读此博客后想到了“连接”字符串:JQuery UI: Change theme dynamically using a drop-down他们有以下代码:
<head>
<link id="stylesheet" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
...
<select id="themes">
<option value="http://code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">Le Frog</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css">Start</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">Smoothness</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/redmond/jquery-ui.css">Redmond</option>
<option value="http://code.jquery.com/ui/1.10.4/themes/sunny/jquery-ui.css">Sunny</option>
</select>
...
这让我想到在之前发布的那条线之后有这条线:
<link id="stylesheet" rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/le-frog/jquery-ui.css">
在我的content.properties
文件中分为3部分,如下所示:
gui.current.theme=south-street
gui.theme.url.part1=//code.jquery.com/ui/1.10.4/themes/
gui.theme.url.part2=/jquery-ui.css
以上这一行分为:
<link id="stylesheet" rel="stylesheet" href="<s:text name="gui.theme.url.part1" /><s:text name="gui.current.theme" /><s:text name="gui.theme.url.part2" />" />
通过这些更改,我能够做我想要的事情,现在我的主题根据我在gui.current.theme
属性中编写的任何主题(包含在ThemeRoller页面中)更改其CSS样式。