为什么struts2自定义类型不会执行?

本文介绍在Struts2框架中如何实现自定义类型的转换,特别是针对复合类型的转换过程。通过配置Action类和Bean类的conversion.properties文件,可以完成自定义类型如日期的转换。

项目结构

image

自定义类型转换类DateConvertor

 

image

 

 

 

 

Aciton 类

image

 

struts.xml

 

image

login.xml:

image

xwork.conversion.properties

image

 

测试页面:

image

 

解决方法:

原来在struts2自定义类型转换复合类型时需要对复合类型设置两个properties

1)在Login-conversion.properties【Action类名-conversion.properties】设置如下:

user.lastLogin=demo.struts2.type.Converter.DateConvertor

2)在复合类型所在包(此处为demo.struts2.beans)下新建一个User-conversion.properties【Bean类名-conversion.properties】

 

lastLogin=demo.struts2.type.converter.DateConvertor

 

转载于:https://www.cnblogs.com/lane_yang/archive/2012/03/15/2397830.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值