2008-04-22
使用Struts2的标签是不是有点恐怖?
关键字: struts
刚刚接触struts2的标签,做了以下一个测式
在jsp的头部加入 <head><s:head /></head>
在<body><s:datetimepicker tooltip="Select Your Birthday" label="生日"
name="birthday" displayFormat="yyyy-MM-dd"/>
</body>
当执行上面的jsp时,页面得到的结果如下:
<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/>
<script type="text/javascript">
// Dojo configuration
djConfig = {
baseRelativePath: "/struts/dojo",
isDebug: false,
bindEncoding: "UTF-8",
debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
};
</script>
<script type="text/javascript"
src="/struts/dojo/dojo.js"></script>
<script type="text/javascript"
src="/struts/simple/dojoRequire.js"></script>
<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/>
<script type="text/javascript">
// Dojo configuration
djConfig = {
baseRelativePath: "/struts/dojo",
isDebug: false,
bindEncoding: "UTF-8",
debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
};
</script>
<script type="text/javascript"
src="/struts/dojo/dojo.js"></script>
<script type="text/javascript"
src="/struts/simple/dojoRequire.js"></script>
可以正常显示,但是在firefox 用firebug 的YSlow插件测式,在本机都要用个三四秒,只是为了加一个日期选择,整个页面就被引入了481KB,YSlow的平分由98分,降到42分,太惨不忍赌了,不知道大家都用些什么方式引入日期选择器呢?
这些都是struts标签包装好的,struts2引入的dojo.js就有二百多KB,如果网速慢还得了,在本机都要用个3秒中,再加上页面的查询,那不是要命么,不知道有没有其它用法
在jsp的头部加入 <head><s:head /></head>
在<body><s:datetimepicker tooltip="Select Your Birthday" label="生日"
name="birthday" displayFormat="yyyy-MM-dd"/>
</body>
当执行上面的jsp时,页面得到的结果如下:
<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/>
<script type="text/javascript">
// Dojo configuration
djConfig = {
baseRelativePath: "/struts/dojo",
isDebug: false,
bindEncoding: "UTF-8",
debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
};
</script>
<script type="text/javascript"
src="/struts/dojo/dojo.js"></script>
<script type="text/javascript"
src="/struts/simple/dojoRequire.js"></script>
<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/>
<script type="text/javascript">
// Dojo configuration
djConfig = {
baseRelativePath: "/struts/dojo",
isDebug: false,
bindEncoding: "UTF-8",
debugAtAllCosts: true // not needed, but allows the Venkman debugger to work with the includes
};
</script>
<script type="text/javascript"
src="/struts/dojo/dojo.js"></script>
<script type="text/javascript"
src="/struts/simple/dojoRequire.js"></script>
可以正常显示,但是在firefox 用firebug 的YSlow插件测式,在本机都要用个三四秒,只是为了加一个日期选择,整个页面就被引入了481KB,YSlow的平分由98分,降到42分,太惨不忍赌了,不知道大家都用些什么方式引入日期选择器呢?
这些都是struts标签包装好的,struts2引入的dojo.js就有二百多KB,如果网速慢还得了,在本机都要用个3秒中,再加上页面的查询,那不是要命么,不知道有没有其它用法


评论
标记库并不代表struts2啊,你觉得标记库不好用可以不用啊,或者自己封装啊。
我个人觉得struts2的标记库render机制还是挺好的,用模板实现,速度虽然慢点但是基本上就相当于用freemarker开发标记库了。
这就像没有必要因为老婆长了个痣就不要她了。
在struts2的有些标签中竟然引入了 dojo js类库,晕就一个字!恐怖。。。。。
呵呵………………
严重同意啊,特别是丫的自做主张给每个textfield包上tr td,搞得排版都排不了了.
验证和验证提示也是一个很恶心的东西,貌似如果不修改的话,验证信息肯定会跑到textfield的下一行.
我后来继承struts2的form,封装了个form标签并且结合jquery验证框架给解决了,窃以为这样作的好处就是可以不用修改struts2本身的代码,不会影响到struts2后续版本的升级.
<s:form theme="simple" .... />
配置struts.xml添加
<constant name="struts.ui.theme" value="simple" />这样就可以指定所有tag的theme.
另外ajax和validation我都用jquery来搞定,特别是jquery的那个检验插件相当的好用.
大家有没有什么好的js校验框架推荐的啊.
汗……
<s:form theme="simple" .... />
默认xhtml那个用表格的太恶心..
我倒觉得theme系统挺好...不爽了可以自己去写一套..
个人感觉那些个theme都很鸡肋.强烈的想知道,大家在项目中是否使用simple之外的其它theme?
另外我对struts2的tag也很不喜欢.但是没办法,要想正常的使用struts2,就必须使用它的标签.尤其是关于form表单的一些标签,真是心里觉得有点别扭.
希望了解大家都是怎么用的.
我一般只用<s:property..
如果换成freemarker页面的话,这个也不用了。
现在还是觉得纯粹的html+css+js可读性较高。标签又不能完全封装好,每换个framework还要再学一次,没什么价值。
FORM TAG 感觉还是很方便的,可以直接调用ACTION里的属性和方法
个人感觉那些个theme都很鸡肋.强烈的想知道,大家在项目中是否使用simple之外的其它theme?
另外我对struts2的tag也很不喜欢.但是没办法,要想正常的使用struts2,就必须使用它的标签.尤其是关于form表单的一些标签,真是心里觉得有点别扭.
希望了解大家都是怎么用的.