您的位置:首页 > 数据库

Sql Server实用操作小技巧集合

2007-11-15 09:07 381 查看
一、首先转换Date类型
1、首先定义一个DateFormat.jsp

<body>
<form action="DateFormat.action"  method="post">

Birthday:<input type="text" name="birthday" size="20">
<br>
<input type="submit" name="sumbit" value="sumbit">

</form>
</body>
2、定义转化action类 在com.test.action中定义DateFormatAction.class
package com.test.action;
import java.util.Date;
import com.opensymphony.xwork2.ActionSupport;
/**
* action处理类  对Date类型进行转换
* @author Administrator
*
*/
public class DateFormatAction extends ActionSupport{

private Date birthday;

public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String execute() {
return "success";
}
}
3、在src目录下定义一个struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts SYSTEM "struts-2.3.dtd">

<!-- PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"  -->
<struts>
<package name="struts2" extends="struts-default">

<action name="DateFormat" class="com.test.action.DateFormatAction" method="exec         ute">

<result name="success">/result.jsp</result>

</action>

</package>
其中<action name="" class="">
name为DateFormat.jsp中action的值,class为刚刚中com.test.action 中定义的类
其中<result name="success">/result.jsp</result> name为com.test.action中DateFormatAction.class中execute()方法返回的String类型的值,
result.jsp为跳转页面,也就是输出结果的页面
4、定义result.jsp进行结果输出
这里直接 使用的是struts2提供的标签库
需在jsp开始引入<%@ taglib uri="/struts-tags" prefix="s" %>即可
<body>
birthday:<s:property value="birthday"/>
</body>
二、自定义类型转换器以转换Point为例
1、
2、
3、
4、
5、
6、
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: