Struts2 标签
来源:互联网 发布:备用信用证知乎 编辑:程序博客网 时间:2024/06/11 08:44
<s:date>标签
Data标签方便在页面进行格式化的日期输出。格式有多种可供选择。同时,还可以通过在properties属性文件中定义好”struts.date.format”参数的值,从而自定义格式输出。
Date标签包含三个属性,可以从下面的代码中感受一下,分别是:
l Name:
l Nice
l Format
1.WebRoot/pages/dataTags/dateTag.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Date Tag 示例</title>
</head>
<body>
<h2>显示当前的时间</h2>
<table border="1" width="35%">
<tr>
<td><b>日期格式</b></td>
<td><b>日期</b></td>
</tr>
<tr>
<td>Day/Month/Year</td>
<td><s:date name="currentDate" format="dd/MM/yyyy" /></td>
</tr>
<tr>
<td>Month/Day/Year</td>
<td><s:date name="currentDate" format="MM/dd/yyyy" /></td>
</tr>
<tr>
<td>Month/Day/Year</td>
<td><s:date name="currentDate" format="MM/dd/yy" /></td>
</tr>
<tr>
<td>Month/Day/Year Hour<B>:</B>Minute</td>
<td><s:date name="currentDate" format="MM/dd/yy hh:mm" /></td>
</tr>
<tr>
<td>Month/Day/Year Hour<B>:</B>Minute<B>:</B>Second</td>
<td><s:date name="currentDate" format="MM/dd/yy hh:mm:ss" /></td>
</tr>
<tr>
<td>Nice Date (Current Date & Time)</td>
<td><s:date name="currentDate" nice="false" /></td>
</tr>
<tr>
<td>Nice Date</td>
<td><s:date name="currentDate" nice="true" /></td>
</tr>
</table>
</body>
</html>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Date Tag 示例</title>
</head>
<body>
<h2>显示当前的时间</h2>
<table border="1" width="35%">
<tr>
<td><b>日期格式</b></td>
<td><b>日期</b></td>
</tr>
<tr>
<td>Day/Month/Year</td>
<td><s:date name="currentDate" format="dd/MM/yyyy" /></td>
</tr>
<tr>
<td>Month/Day/Year</td>
<td><s:date name="currentDate" format="MM/dd/yyyy" /></td>
</tr>
<tr>
<td>Month/Day/Year</td>
<td><s:date name="currentDate" format="MM/dd/yy" /></td>
</tr>
<tr>
<td>Month/Day/Year Hour<B>:</B>Minute</td>
<td><s:date name="currentDate" format="MM/dd/yy hh:mm" /></td>
</tr>
<tr>
<td>Month/Day/Year Hour<B>:</B>Minute<B>:</B>Second</td>
<td><s:date name="currentDate" format="MM/dd/yy hh:mm:ss" /></td>
</tr>
<tr>
<td>Nice Date (Current Date & Time)</td>
<td><s:date name="currentDate" nice="false" /></td>
</tr>
<tr>
<td>Nice Date</td>
<td><s:date name="currentDate" nice="true" /></td>
</tr>
</table>
</body>
</html>
2.src/com/sterning/beanTag.java
该项类更加简单,页面跳转
package com.sterning;
import com.opensymphony.xwork2.ActionSupport;
public class beanTag extends ActionSupport {
public String execute() throws Exception{
return SUCCESS;
}
}
import com.opensymphony.xwork2.ActionSupport;
public class beanTag extends ActionSupport {
public String execute() throws Exception{
return SUCCESS;
}
}
3.Struts.xml配置
<action name="dateTag" class="com.sterning.dateTag">
<result>/pages/dataTags/dateTag.jsp</result>
</action>
<result>/pages/dataTags/dateTag.jsp</result>
</action>
4.运行效果
- struts2标签
- struts2标签
- struts2标签
- Struts2 标签
- struts2标签
- struts2标签
- struts2 标签
- Struts2 标签
- Struts2标签
- struts2 标签
- Struts2标签
- struts2标签
- Struts2 标签
- struts2标签
- struts2 标签
- struts2标签
- struts2 标签
- struts2标签
- 火狐浏览器下获得Event对象以及keyCode
- 1089 A+B for Input-Output Practice (I)
- 精通 Grails: 构建您的第一个 Grails 应用程序(转自developmentwork 中国)
- 软件工程师的6年总结
- 1090 A+B for Input-Output Practice (II)
- Struts2 标签
- 1091 A+B for Input-Output Practice (III)
- 1092 A+B for Input-Output Practice (IV)
- 1093 A+B for Input-Output Practice (V)
- 1094 A+B for Input-Output Practice (VI)
- Ant 基础使用
- 1095 A+B for Input-Output Practice (VII)
- 1096 A+B for Input-Output Practice (VIII)
- 1228 A + B