I had tried both but when i used 1st i didn't get validation message i.e "empname is required" that i wrote in action-validation.xml although validation is working well. please comment ?
但使用标准 HTML 标签的缺点是会失去一些功能,毕竟这就是自定义标签存在的首要原因。 即使使用标准 HTML,也可以通过控制器类上的验证方法进行验证。
如果您刚刚开始使用该框架,我建议您在走出常规道路之前正确学习 struts 标签。
No, it is not mandatory. In fact a lot of struts2 users are sufficiently dissatisfied with OGNL and choose to use regular HTML instead.
But using the standard HTML tags has the drawback of loosing some functionality, after all that's why the custom tags are there in the first place. It is possible to get validation through validate methods on the controller class even with standard HTML.
If you are just starting out with the framework I suggest you learn the struts tags properly before going off the beaten path.
I don't see why you need any tags at all. Couldn't you just use Struts to generate JSON result types and then use calls to those in your otherwise static jsp pages using JavaScript and JQuery?
发布评论
评论(3)
不,这不是强制性的。 事实上,很多 struts2 用户对 OGNL 非常不满意,并选择使用常规 HTML。
但使用标准 HTML 标签的缺点是会失去一些功能,毕竟这就是自定义标签存在的首要原因。 即使使用标准 HTML,也可以通过控制器类上的验证方法进行验证。
如果您刚刚开始使用该框架,我建议您在走出常规道路之前正确学习 struts 标签。
No, it is not mandatory. In fact a lot of struts2 users are sufficiently dissatisfied with OGNL and choose to use regular HTML instead.
But using the standard HTML tags has the drawback of loosing some functionality, after all that's why the custom tags are there in the first place. It is possible to get validation through validate methods on the controller class even with standard HTML.
If you are just starting out with the framework I suggest you learn the struts tags properly before going off the beaten path.
不,但是如果您根本不使用标签,那么您就无法真正从 Struts 这个框架中获得太多好处。 不妨自己做一下。
如果您使用自己的标记,则必须告诉它显示错误消息。 例如。:
请停止一遍又一遍地问同样的问题。
No, but if you aren't using tags at all then you're not really getting very much out of Struts as a framework. Might as well do it yourself.
If you're using your own markup you'll have to tell it to display the error message. eg.:
Please stop asking the same questions over and over again.
我根本不明白为什么你需要任何标签。 难道您不能只使用 Struts 生成 JSON 结果类型,然后使用 JavaScript 和 JQuery 调用静态 jsp 页面中的结果类型吗?
I don't see why you need any tags at all. Couldn't you just use Struts to generate JSON result types and then use calls to those in your otherwise static jsp pages using JavaScript and JQuery?