`

struts2中日期标签的<sx:datatimepicker>的使用

阅读更多

今天用到了struts2的日期标签;整了一个下午没有整好.晚上回来上网查了一下。发现晚上这个问题不少但是都没有得到解决;算了 自己动手丰衣足食啊!

查看官方文档:

 

Description

To use the AJAX tags from 2.1 on you must:

  • Include the Dojo Plugin distributed with Struts 2 in your /WEB-INF/lib folder.
  • Add <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> to your page.
  • Include the head tag on the page, which can be configured for performance or debugging purposes.

点击head连接:

 

Description

The "head" tag renders required JavaScript code to configure Dojo and is required in order to use any of the tags included in the Dojo plugin.

 

 

 

 

 

To debug javascript errors set the "debug" attribute to true, which will display Dojo (and Struts) warning and error messages at the bottom of the page. Core Dojo files are by default compressed, to improve loading time, which makes them very hard to read. To debug Dojo and Struts widgets, set the "compressed" attribute to true. Make sure to turn this option off before moving your project into production, as uncompressed files will take longer to download.

For troubleshooting javascript problems the following configuration is recommended:

  <sx:head debug="true" cache="false" compressed="false" />
 

 

 

这就是结果:

 

 

直奔主题:

我的 代码:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>
<html>
<head>
 <sd:head debug="true" cache="false" compressed="false" />
</head>
<body>

<s:form method="post" theme="simple">
	<sd:datetimepicker name="startDate" toggleType="explode"
		toggleDuration="400" displayFormat="yyyy-MM-dd" id="start"
		value="today" label="date">
	</sd:datetimepicker>
	<s:submit value="submit"></s:submit>

</s:form>

</body>

 

 

后来试了一下 代码该为这样也可以:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>
<html>
<head>
<sd:head />
</head>
<body>

<s:form method="post" theme="simple">
	<sd:datetimepicker name="startDate" toggleType="explode"
		toggleDuration="400" displayFormat="yyyy-MM-dd" id="start"
		value="today" label="date">
	</sd:datetimepicker>
	<s:submit value="submit"></s:submit>

</s:form>

</body>

 

确定在我的机器上可以运行并且出来结果: 我用的是eclipse 3.5

 

要在WEB-INF/lib下面添加struts2-dojo-plugin.2.1.8.1.jar包;

 

 

在这里我先说以下我也是刚接触struts2 我还不知道这是为什么? 希望那位大虾给指点指点。。。。。。。。

分享到:
评论

相关推荐

    windows应用高级编程-C#编程篇.part1

    菜单和工具栏&lt;br&gt;4.1 菜单控件和类&lt;br&gt;4.1.1 创建主菜单&lt;br&gt;4.1.2 创建上下文菜单&lt;br&gt;4.2 工具栏控件和类&lt;br&gt;4.2.1 创建工具栏&lt;br&gt;4.2.2 显示/隐藏工具栏&lt;br&gt;4.3 小结&lt;br&gt;第5章 使用图形&lt;br&gt;5.1 设备语境&lt;br&gt;5.2 ...

    WPF日期时间选择DateTimePicker

    - `DateTimePicker`控件在XAML中的声明非常简单,只需在适当的位置添加`&lt;wpf:DateTimePicker /&gt;`标签,其中`wpf`是引用WPF命名空间的别名。 - 默认情况下,控件会显示当前日期和时间,可以通过`Value`属性来获取或...

    用开源项目DataTimePicker实现时间日期选择功能

    通过创建主题或者在XML布局中使用自定义属性,你可以调整选择器的颜色、字体大小、动画效果等。例如,如果你想改变日期选择器的背景颜色,可以在主题中定义如下: ```xml &lt;style name="AppTheme.DateTimePicker" ...

    jquery.DataTimePicker.js 日历插件

    &lt;script src="path/to/jquery.datetimepicker.full.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" id="datetime-input"&gt; &lt;script&gt; $(function(){ $('#datetime-input').datetimepicker({ format: 'Y-m...

    flex DataTimePicker时间控件

    在Flex项目中使用DataTimePicker,需要首先确保安装了相关的库或框架。通常,这可以通过在项目配置中添加依赖或引用库文件完成。之后,在代码中导入相应的类,例如`import mx.controls.DateTimePicker;`。 3. **...

    Datatimepicker控件常见使用

    Datatimepicker控件在软件开发中是一种常用的用户界面组件,它允许用户选择日期和时间。这个控件在各种应用程序中都有广泛的应用,比如日程安排、预订系统、时间记录等。在这里,我们将深入探讨Datatimepicker控件的...

    Android中DateTimePicker的实现

    在Android开发中,DateTimePicker是用户界面中一个重要的组件,用于选择日期和时间。这个组件让用户能够方便地设定日期(年、月、日)和时间(小时、分钟),通常用于设置提醒、创建事件或者填写表单等场景。下面将...

    Bootstrap和seajs结合的分页器

    &lt;li class="page-item"&gt;&lt;a class="page-link" href="#"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li class="page-item"&gt;&lt;a class="page-link" href="#"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;li class="page-item"&gt;&lt;a class="page-link" href="#"&gt;Next&lt;/a&gt;&lt;/li&gt; &lt;/ul...

    datatimepicker.rar

    标签中的"bootstrap-datetime"指的是与Bootstrap相关的日期时间组件,"日期时间控件"和"日期时间选择插件"则明确了DateTimepicker的性质,即一个用于选择日期和时间的插件。"DateTime"则是对所处理数据类型的描述。 ...

    DateTimePicker:jQuery日期和时间神器

    DateTimePicker是jQuery库中的一个强大工具,用于在网页表单中添加日期和时间选择功能。这个插件使得用户能够方便地选取日期和时间,而无需手动输入,极大地提高了用户体验。以下将详细介绍DateTimePicker的特性、...

    Android自定义DataTimePicker实例代码(日期选择器)

    在标准的Android SDK中,虽然提供了`DatePicker`和`TimePicker`两个组件,但它们通常是分开使用的,如果需要在一个视图中同时选择日期和时间,就需要进行自定义。本文将详细讲解如何创建一个自定义的`DateTimePicker...

    bootstrap-datetimepicker.zip

    使用Bootstrap DateTimePicker时,你需要在HTML中添加对应的元素(通常是`&lt;input&gt;`标签),并使用JavaScript进行初始化配置。例如: ```html &lt;input type="text" id="datetimepicker" /&gt; ``` ```javascript $...

    JavaFX_ DateTimePicker.jar

    JavaFX中的日期时间选择控件,来自于github开源项目https://github.com/taipeiben/DateTimePicker,这个是自己打包的jar

    自定义TimePicker和DataPicker

    在Android开发中,TimePicker和DatePicker是两种常用的控件,分别用于选择时间(小时、分钟)和日期(年、月、日)。然而,系统提供的默认样式可能无法满足所有设计需求,因此开发者有时需要自定义这些控件以实现...

    时间选择器

    在Android开发中,用户界面(UI)的设计是至关重要的,特别是在需要用户输入特定日期或时间时。"时间选择器"是这样一个组件,它允许用户在应用程序中方便地选取日期和时间,而无需手动输入所有细节。这个主题主要...

    datetimepicker选择时分秒

    在本项目中,我们聚焦于"bootstrap-datetimepicker",这是一个基于Bootstrap框架的日期时间选择器插件。经过改造后,该插件现在支持用户不仅可以选择日期,还可以精确地选择时、分、秒,极大地提升了输入时间数据的...

    bootstrap-timepicker双击问题修复

    最近在项目中引用了bootstrap-datatimepicker控件,但是发现该控件在日期选择框弹出状态下再次点击input则日期选择框消失但再次点击input日期选择框不再弹出。 解决办法: 在日期控件的show方法中给input加上...

    动态加载模块

    在给定的压缩包文件中,"DataGrid控件动态加载控件示例(ComboBox及DataTimePicker)"是一个具体的实践案例,展示了如何在.NET环境中动态加载和使用控件。DataGrid控件是用于显示表格数据的UI组件,而ComboBox和...

Global site tag (gtag.js) - Google Analytics