浏览 2686 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-05-17
尝试在jsp页面中使用Struts 2的datetimepicker:
<%@page pageEncoding="GBK" contentType="text/html; charset=GBK" %> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>编辑员工</title> </head> <body> <s:form name="editForm" action="save" validate="true"> <s:datetimepicker label="生日" name="employee.birthday" displayFormat="yyyy-MM-dd"/> <!--其它代码略--> </s:form> </body> </html> 运行时发现仅能显示“生日”标签,而日期编辑框和下拉按钮都没有显示 对比了Struts 2的showcase里的例子源码,页面上没有其它与datetimepicker这个tag相关的代码了;再对比运行时生成的页面内容,发现showcase的页面有如下script而我的页面上却没有: <script language="JavaScript" type="text/javascript">
// Dojo configuration
djConfig = {
baseRelativePath: "/struts2-showcase-2.0.6/struts/dojo",
isDebug: false,
bindEncoding: "UTF-8",
debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
};
</script>
<script language="JavaScript" type="text/javascript"
src="/struts2-showcase-2.0.6/struts/dojo/dojo.js"></script>
<script language="JavaScript" type="text/javascript"
src="/struts2-showcase-2.0.6/struts/simple/dojoRequire.js"></script>
把这段代码适当修改后加到我的页面上,datetimepicker终于能正常显示了 我的疑问是:为什么showcase可以自动生成以上script,而我的页面却没有呢?查了showcase的配置文件,似乎没有发现什么特别的地方 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
| 返回顶楼 | |
|
时间:2007-05-17
我也遇到的类似的问题,现在还没解决。http://www.javaeye.com/my_topic/79888
盼高手出现。 我使用富文本标签不能显示,脚本代码能够生成,但报错。貌似是路径问题(因为我把路径指向showcase时,能显示)。 |
|
| 返回顶楼 | |
|
时间:2007-05-17
哈哈,问题解决了!
又仔细看了showcase中的代码,发现在<head></head>部分有如下代码,在我的页面上却漏掉了: <s:head /> 很简单的一句却是关键!原因在手册中说明了: 引用 Renders parts of the HEAD section for an HTML file. This is useful as some themes require certain CSS and JavaScript includes.
If, for example, your page has ajax components integrated, without having the default theme set to ajax, you might want to use the head tag with theme="ajax" so that the typical ajax header setup will be included in the page. The tag also includes the option to set a custom datepicker theme if needed. See calendarcss parameter for description for details. If you use the ajax theme you can turn a debug flag on by setting the debug parameter to true. |
|
| 返回顶楼 | |
|
时间:2007-10-01
能不能显示日期和时间的选择呢?
|
|
| 返回顶楼 | |
|
时间:2007-11-12
我也有同样问题,也按照楼上方法做了,但还是没有出现,请问还有其他原应吗?
|
|
| 返回顶楼 | |
|
时间:2008-04-09
"/struts/dojo"目录是怎么处理的;需要手动建立相应的目录并将dojo的相关js拷贝到其中还是Struts2自动完成的?若自动处理,相关的js文件在那里?
|
|
| 返回顶楼 | |
|
时间:2008-04-22
我感觉会引入很多JS,网页变得好了
http://www.javaeye.com/topic/185464 |
|
| 返回顶楼 | |
|
时间:2008-04-24
楼主说的对 主要就是
<s:head /> 的原因 |
|
| 返回顶楼 | |









