惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
GbyAI
GbyAI
B
Blog RSS Feed
H
Help Net Security
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Cloudflare Blog
Security Latest
Security Latest
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
P
Privacy & Cybersecurity Law Blog
J
Java Code Geeks
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threatpost
Schneier on Security
Schneier on Security
T
Tenable Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Latest news
Latest news
P
Proofpoint News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
G
GRAHAM CLULEY
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
博客园_首页
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threat Research - Cisco Blogs
T
Tor Project blog
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
月光博客
月光博客

博客园 - 锐

Windows7 Server 2008 下安装Oracle 10g提示“程序异常终止,发生未知错误”的解决方法 Android应用自动更新功能的代码实现 Undefined exploded archive location 项目不能部署 linux下mysql5.5.19编译安装笔记【已验证】 CSS+DIV排版时容器内对象全部设置了float属性后容器不能自动适应高度的解决方案 php Smarty模板生成html文档的方法 - 锐 - 博客园 如何解决Firefox检测不到div高度问题 DD_belatedPNG,解决IE6不支持PNG绝佳方案 .net程序运行在无.net framework环境中 struts2 freemarker当中引进java 常量java静态方法 - 锐 简体-繁体互转换的一个JS - 锐 - 博客园 C#实现通过URL触发自己的程序 Tencent://Message/协议的实现原理 - 锐 - 博客园 国内三大免费流媒体WAP门户网站(视频类WAP网站) C#中RSA加密解密和签名与验证的实现 (转) C#读取CPUid,硬盘id,网卡Mac地址 java -D参数简化加入多个jar MySQL Proxy 学习笔记(转) 用apache ab做web压力测试
Struts2.1.6使用小技巧
· 2010-06-24 · via 博客园 - 锐

1,对数字货币的格式化.

Struts2.1.6的格式化需要两点.

--struts2.1.6的资源文件,里面需要加上以下的配置,(一般写在英文的文档里面,也是默认的.)

format.time = {0,date,yyyy-MM-dd}

format.number = {0,number,\#0.00\#\#} 

format.percent = {0,number,\#\#0.00'%'} 

# {0,number,¥##0.00元} 

format.money = {0,number,\uFFE5\#\#0.00\u5143} 

JSP页面中需要借助,<s:text>标签配合使用.具体代码如下:

<s:text name="format.money">-- format.money是在资源文件里面定义的格式

    <s:param value="#goods.marketPrice"/>

</s:text>

2,时间的格式化

可以通过和数字货币的格式一样方式来实现格式化,参见方式1.

也可以通过<s:date>来实现时间的格式化

<s:date name="###" format="yyyy-MM-dd HH:mm:ss"/>

3,struts2.1.6的配置文件中定义变量.

先看段代码吧.

<package name="web" extends="struts-default" namespace="/">

    <action name="goodsList_*" class="goodListAction" method="{1}">

       <result name="goodssuc">

           /template/${template}/goods/goodslist.jsp

       </result>

    </action>

</package>

看下Result中的网址, 用它来表示模板太方便不过了.网上有很多软件和博客空间都提供换皮肤的功能,如果要实现这样的功能,我们可以为每套皮肤都写各自的程序,全部放在template的文件夹下,名字就是皮肤名来取名.而所有的返回的网站都加上${template}来表示是跳转到哪套皮肤的页面下.(前题是所有的皮肤下的页面名字要起的一样.)

而${template}这个变量如何赋值呢?

Struts2.1.6有类似的功能,可以用$来输出变量,有点像EL表达式,里面的变量名,在对应的Action里面要做为属性存在,并且提供相应的读写器(get和set方法).

既然是皮肤,每个Action里面都有.可以为所有的Action建一个父类,如BaseAction,让BaseAction继承自ActionSupport(struts2.1.6里面的),把公共的方法和变量可以写在这里面,如template就可以做为BaseAction的属性.