j2ee都是远程调用,所以,应该很耗资源,如果在c--s间反复传输,不仅增加网络负荷也,太好资源。所以应该在client端做校验。这是最好的办法,也是必须的。

解决方案 »

  1.   

    我看了一些资料,说client端的校验并不是一个好的解决方案,这是它上面说的:
    Client-side Scripting: Inflexible and Non-portable
    Client-side data validation was the first generation of user input data validation technology for web applications. It is still widely used today. The data validation logic is typically implemented in HTML and Javascript and embedded in the Web pages transmitted to the browser. While it provides faster response time by reducing the number of round trips to the server, this approach has the following shortcomings:Successful data validation relies heavily on client-side configuration. An end user might choose to have Javascript disabled in her browser for security reasons or simply to avoid popup advertisements. Also, different browsers support subtly different feature sets of Javascript; it's often necessary to use different APIs in different browsers to do the same thing. 
    Complex data validation logic usually needs to access data stored on the server. For example, a client-side snippet of Javascript is able to check whether a ZIP code is well-formed, but a more sophisticated application would want to further validate the ZIP code by searching a ZIP code database stored on a Web or database server. 
    The data validation logic, an integral part of the business logic, is removed from the business layer and combined with the presentation layer. This violates the principles of three-tiered architecture, introducing unnecessary coupling that reduces flexibility. 
      

  2.   

    数据校验应该是在客户端和服务器端进行双方面的检查,这样才能保证数据的安全性和正确性。一般在客户端是通过javacript语言来检查和控制的,在服务器端则也应该通过java语言来进行校验和判断。如果单单在客户端进行判断是不够的,想想很简单,因为javascript是用户自己定义和编写的,本身就没有很高的安全性。
      

  3.   

    用js做校验的缺陷已经很明显了。
    请问一下lovevicky511(郭志军),在server端校验就足够了,为什么还要在client做呢?server client同时做的话不是一种重复和浪费吗?
    这几天在网上搜了一些 form validation的资源,和大家分享,希望对大家有帮助
    Form Validation on the Client Side 
    - 讲了基本的javascript form validation
    http://www.webmasterbase.com/article/862Form Validation on Steroids 
    - 一个别人写的javascript form validation
    http://jennifermadden.com/steroidVal/formDocumentation.htmlYet Another Article on Client Side Form Validation 
    - 用dom和输入框的待殊属性来进行校验
    http://www.webmasterbase.com/article/661Advanced form processing using JSP 
    - javaworld.com上的一篇文章
    http://www.javaworld.com/javaworld/jw-03-2000/jw-0331-ssj-forms.htmlHTML form processing, HTML form validation 
    - google新闻组上有人列出了一些form validation的资源
    http://groups.google.com/groups?q=java+form+validation&hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&selm=tPyd9.200084%24aA.39457%40sccrnsc02&rnum=3
    以下是它的内容
    -------------------------------------------------------------------------------------
    I would like to hear from others regarding techniques for
    validating HTML form data in a web applicationI already found these resources:http://www.javaworld.com/javaworld/jw-04-2001/jw-0427-forms.html
    Barracuda Form
    Validatorhttp://barracuda.enhydra.org/cvs_source/Barracuda/docs/forms/high_l
    evel_overview.html
    http://formproc.sourceforge.net/  ( http://www.formproc.org/ )article: Java and XML: Learn a Better Approach To Data Validation
    - 这篇讲得很好,讲了validation应该怎样做才是好的
    http://www.devx.com/java/free/articles/schwartz0402/schwartz0402-1.aspWeblogic JSP form validation tags
    http://edocs.bea.com/wls/docs70/jsp/validation_tags.htmlForm Processing API
    http://www3.sympatico.ca/iostro/fpapi2.0/Validation JSP taglib
    http://www.servletsuite.com/servlets/validtag.htmForm processing chapter in "Java Servlets by Example"
    http://www.manning.com/Williamson/Contents.htmlStruts API: org.apache.struts.validator.action.ValidatorForm
    http://jakarta.apache.org/struts/Jakarta Commons commons-validator
    http://jakarta.apache.org/commons/components.html
    article: Handling HTML Forms
    http://java.sun.com/products/jsp/html/jspbasics.fm2.html
    --------------------------------------------------------------------------------
      

  4.   

    对于安全性要求不是很高的数据在Client端校验。
      

  5.   

    看了半天,才明白校验是参数检查。我还以为是CRC32什么的:(