简体   繁体   English

Struts2验证还是HTML5验证?

[英]Struts2 Validation or HTML5 validation?

Which have a better validation, HTML5 or Struts2? HTML5或Struts2哪个具有更好的验证能力? I was developing a project using the Struts2 structure but I am always confused and getting difficulties with it, and I found out that there is a validation at HTML5. 我当时正在开发使用Struts2结构的项目,但是我总是很困惑,并且在使用它时遇到了困难,而且我发现HTML5上有一个验证。 So I was wondering if it is more reliable if I use HTML5 rather than the Struts2 validation. 所以我想知道如果使用HTML5而不是Struts2验证是否更可靠。

Validation in HTML5 would be at the client end. HTML5中的验证将在客户端进行。 Also if you have a browser that doesn't support complete HTML5 based validation, then they would not work. 另外,如果您的浏览器不支持基于HTML5的完整验证,那么它们将无法工作。
Struts2 is a server side validation, which means if a client manages to send incorrect data it would be rejected at your server side. Struts2是服务器端验证,这意味着如果客户端设法发送不正确的数据,它将在您的服务器端被拒绝。
In my opinion it is a MUST to have a Server Side validation (struts2 in your case) if your application is external facing (ie exposed to external users). 我认为,如果您的应用程序是面向外部的(即暴露给外部用户),则必须进行服务器端验证(在您的情况下为struts2)。 Client side validations (HTML5) can support you to make the experience faster. 客户端验证(HTML5)可以帮助您更快地体验。 For more details refer here 有关更多详细信息,请参见此处

Struts2 validation is not the purely server side validation and not a client side validation too. Struts2验证不是纯粹的服务器端验证,也不是客户端验证。 Its taken as front-end validation of web application. 它被用作Web应用程序的前端验证。 By the way you can use this as your preference. 顺便说一下,您可以将其用作您的首选项。 All the clients are not well support for html5. 所有客户端都不太支持html5。 So its better to choose struts2 validation. 因此最好选择struts2验证。 You would be able to do it on separate validation xml file. 您将能够在单独的验证xml文件中执行此操作。 But its not must. 但这不是必须的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM