zoukankan      html  css  js  c++  java
  • struts2 json 传输数据

    $(document).ready(function(){

      $("#a").blur(function(){ 

        var str =  $("#a").val(); // 得到焦点内容

    // var str=document.getElementById("a").value; 

    var reg = /^[/u4e00-/u9fa5]+$/i; //验证只能输入汉字的正则表达式

    if (!reg.test(str)) 

    {

    alert("请输入中文名字!"); 

    document.form1.a.focus(); 

    //str.focus();

    return false; 

    }

       return true;

       });

    });

     .action 中所写的

    /**

    * 检测邮箱是否存在

    * @return

    * @throws Exception

    */

    public String emailCheck() throws Exception {

    String email = (String) this.baseServiceIbatis.findObject("euser.eemailCheck", euser.getEmail());

    if(email==null){

    euser.setEmail("");

    list = new ArrayList();

    list.add(euser);

    this.outJson(list, JsonType.Array);

    return SUCCESS;

    }

    .jsp 页面所写的

    //email账号

    $("#adminusername").blur(function(){

    var email = $(this).val();

    if(email==""){

    $("#tip_adminusername").html("").html("<font color='red'>请输入EMAIL地址!</font>");

    return;

    }

    if(!testEmail(email)){

    $("#tip_adminusername").html("").html("<font color='red'>EMAIL地址格式不正确!</font>");

    return;

    }

    $.getJSON("enterprise/users/emailCheck.action", {"user.email":email}, function(json){

    email = json[0].email;

     if(email==""){

      $("#tip_adminusername").html("").html("<font color='green'>恭喜你,你的邮箱可以注册!</font>");

      emailIsPass = true;

     }else{

      $("#tip_adminusername").html("").html("<font color='red'>该邮箱已注册!</font>");

      emailIsPass = false;

     }

     });

    });

    //用户名

    $("#admintruename").blur(function(){

    if($(this).val()==""){

    $("#tip_admintruename").html("").html("<font color='red'>管理员名称不能为空!</font>");

    return false;

    }

    });

    if(emailIsPass=false){

    $("#tip_adminusername").html("").html("<font color='red'>该邮箱已经注册!</font>");

    }

    struts.xml 中配置

    <action name="emailCheck" class="euserAction" method="emailCheck">

    <!-- <result type="json" />-->

    </action>

  • 相关阅读:
    JVM调优总结(转载)
    项目应该如何分层(转载)
    SpringCloud Feign 配置(基于Consul)
    yml配置文件嵌套
    SpringCloud Zuul基于Consul配置及详解
    springBoot聚合项目打包
    SpringCloud Config 配置(基于Consul)
    hibernate的三种状态
    IOS 图片全屏预览
    IOS 下拉菜单
  • 原文地址:https://www.cnblogs.com/java20130726/p/3218423.html
Copyright © 2011-2022 走看看