今天用到了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 我还不知道这是为什么? 希望那位大虾给指点指点。。。。。。。。