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 我還不知道這是爲什麼? 希望那位大蝦給指點指點。。。。。。。。

發佈了83 篇原創文章 · 獲贊 6 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章