<s:if>标签与ActionContext.getContext().getSession()
今天在做<s:if>标签中的属性值从 ActionContext.getContext().getSession().put("WW_TRANS_I18N_LOCALE",LocaleUtils.toLocale(locale_language)); 中获取值进行判断是,判断结果总是为false。
JSP页面:
<s:if test='#session.WW_TRANS_I18N_LOCALE=="zh_TW"'>
111
</s:if>
<s:else>
222
</s:else>
判断#session.WW_TRANS_I18N_LOCALE=="zh_TW"的结果总是为false,尝试了<s:if test='#session.WW_TRANS_I18N_LOCALE=="zh_TW".toString()'>
和<s:if test='#attr.WW_TRANS_I18N_LOCALE=="zh_TW"'>均无法实现想要的结果。
在JSP页面上用 <s:property value="#session.WW_TRANS_I18N_LOCALE"/>可以得到正确的结果,可是判断就是不行。
后面使用了如下方法,解决了问题:
<% request.setAttribute("lang",ActionContext.getContext().getSession().get("WW_TRANS_I18N_LOCALE").toString()); %>
<s:if test='#request.lang=="zh_TW"'>
111
</s:if>
<s:else>
222
</s:else>
上面各种方法不能实现的原因暂时还没搞清楚,不过已经实现了自己想要的效果。
<s:if>怎么引用页面的变量进行判断?
<s:set var="tNam"><%=Constant.AD_TEMPLATE_TYPE_COMMON%></s:set>
<s:if test="adStyle eq #tNam">
<s:if test="adTemplateList.size>0">
<s:iterator value="adTemplateList" id="adTemplate" status="c">
<td style="text-align: center">
<div>
<a target="navTab" title="普通广告新增" class="tmpSelect"
rel="toAddCommon"
href="ad/adPackage!toAddCommon.do?adPackage.adTemplateId=<s:property value='#adTemplate.adTemplateId'/> && adStyle=<s:property value='adStyle'/>">
<img id='tempList<s:property value="#c.index+1"/>'
src="<s:property value='#adTemplate.adTemplatePath'/>"
style="height: 254px; width: 171px;" /> <br> <span><s:property
value="#adTemplate.adTemplateName" /></span>
</a>
</div>
</td>
</s:iterator>
</s:if>
</s:if>
<s:if>标签与ActionContext.getContext().getSession()的更多相关文章
- ActionContext.getContext().getSession()
ActionContext.getContext().getSession() 获取的是session,然后用put存入相应的值,只要在session有效状态下,这个值一直可用 ActionConte ...
- ServletActionContext.getRequest().getSession() 和 ActionContext.getContext().getSession()
ActionContext.getContext().getSession(); 这个方法获取的session是struts封装过的一个Map类型的session,只能调用put()方法缓存数据. S ...
- 关于ActionContext.getContext()的用法心得
转: 为了避免与Servlet API耦合在一起,方便Action类做单元测试,Struts 2对HttpServletRequest.HttpSession和ServletContext进行了封装, ...
- 关于ActionContext.getContext()的用法
为了避免与Servlet API耦合在一起,方便Action类做单元测试,Struts 2对HttpServletRequest.HttpSession和ServletContext进行了封装,构造了 ...
- 【转载】关于ActionContext.getContext().getParameters()获值问题
ActionContext.getContext().getParameters():一个学员问题的解答 2012-11-12 15:12:05| 分类: 默认分类 | 标签:struts2 ...
- 关于ActionContext.getContext()的使用方法心得
这个也是我在另外一位仁兄的博客中看到的,原博客的有点长,我把它精简了一下,算看起来比較方便吧. 为了避免与Servlet API耦合在一起,方便Action类做单元測试,Struts 2对HttpSe ...
- 大约ActionContext.getContext()使用体验
这是我在另一个人的博客看了,原来博客的时间长一点.我把它简化了一下,运营商,以方便它看起来. 为了避免与Servlet API耦合在一起,方便Action类做单元測试,Struts 2对HttpSer ...
- ActionContext.getContext()用法
为了避免与Servlet API耦合在一起,方便Action类做单元测试,Struts 2对HttpServletRequest.HttpSession和ServletContext进行了封装,构造了 ...
- ValueStack与ContentMap (ActionContext.getContext().getValueStack().set())
在方法 <action name="zilei" class="dtreeAction" method="zilei"> & ...
随机推荐
- VS 调试Window Server方法
在需要调试的地方加 Debugger.Launch();然后在本机安装服务并启动即可进入
- beforefieldinit释义(2)
首先来看一段代码: using System; namespace BeforeFieldInit { internal class Foo { Foo(){ Console.WriteLine(&q ...
- Collections类方法详解
Collections则是集合类的一个工具类/帮助类,其中提供了一系列静态方法,用于对集合中元素进行排序.搜索以及线程安全等各种操作. 1) 排序(Sort)使用sort方法可以根据元素的自然顺序 对 ...
- js数组(二)
一.位置方法 indexOf()和laseIndexOf() indexOf是从数组的第0项开始向后查找,没有找到返回-1,要求使用=== var numbers = [1,2,3,4,5,4,3,2 ...
- 从头开发MUDLIB
跟Akuma一起从头打造mudlib--[第一讲] 第一讲:让它跑起来注:每一讲我都会上传一个相符的lib,有些文件是旧的,有些是新的,我尽可能在lib里写清楚注释.更详细的内容则在每讲的正文里写. ...
- HTTP中的URL长度限制(资料整理)
HTTP中的URL长度限制 首先,其实http 1.1 协议中对url的长度是不受限制的,协议原文: The HTTP protocol does not place any a priori l ...
- HTTP协议漫谈(转)
转自:http://www.cnblogs.com/CareySon/archive/2012/04/27/HTTP-Protocol.html HTTP的定义和历史 在一个网络中.传输数据需要面临三 ...
- [方法]本来好的中文在winEdt中打开变成乱码
场景:本来在winEdt中使用中文的tex文件,使用xelatex可以编译成pdf,今天打开该tex文件,所有中文变得不可读,统统乱码. 解决方法:在保存tex文件时使用的是utf-8保存的,所以在打 ...
- Static Function Test
public class StaticTestCls { public int x = 0; public static int y = 0; private void SetValue_Object ...
- structs常用的Action
今天座右铭-----谦虚使人进步,骄傲使人落后. 除了基本的Action之外,structs还提供几个其他的类型Action,下面就简单的说一下: 1.DispatchAction:能同时完成多个Ac ...