javascript - json将字符转换为随机字符

标签 javascript jquery json jsp

您好,我的数据库中有电子邮件地址,例如“abc@yahoo.co.in”,当我检索它时,在将该对象返回给客户端之前,我在 Controller 上也得到了相同的地址,但是当我在我的 Controller 上提醒该值时java 脚本页面,“@”正在转换为一些随机字符并且无法正确显示。我该如何解决这个问题?

服务器代码:

enter code here

 public AppUser findById(@FormParam("employeeId") String eId ){

      int id=Integer.parseInt(eId);
      AppUser appUser=null;
      appUser= evaluatorService.findById(id);
      return appUser;
   }

在调试 appUser 时,它为我提供了正确的数据。

我的客户端代码:

 $.ajax({
    type : 'GET',
    url : 'rest/evaluator/fetchEvaluatorById',
    data : {

     'employeeId' : employeeId
    },
    success : function(data) {
     $('#evaluatorDetailEdit').dialog({
      width: 400,
            height: 400,
     });
     alert(data.email);


     $('#employeeId').val(data.employeeId);
     $('#name').val(data.name);
     $('#lastName').val(data.lastName);
     $('#email').val(data.email);


    }
   });

最佳答案

有一些 hacky jquery-workaround - 也许有更好的解决方案,但这应该有效:

var original = "@";
alert("Original: " + original);

// Hacky jquery-workaround: 
// 1. pasting encoded text as html in a "virtual" textarea and
// 2. get the decoded text:
var decoded = $('<textarea/>').html(original).text();
alert("Decoded: " + decoded);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

关于javascript - json将字符转换为随机字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28831753/

相关文章:

javascript - Ajax脚本接收用户字符串输入文本并以JSON格式发布

javascript - 使用javascript从字符串中删除字符

javascript - 如何仅使用 jquery 将行传递到其他表?

javascript - 函数参数的解构

jQuery,如何获取表行中特定复选框的值?

javascript - 当我提交表单时,从 jquery datepicker 中的开始日期和天数计算结束日期

json - 仅在 JSON 之后加载 tableView

javascript - 如何使用 jquery 从 json 对象中获取值?

javascript - 如何使用 jquery 和 javascript 更改 div 的内容?

javascript - 如何在每个 VuetifyJS 组合框条目前添加一个图标?