@RequestMapping("/check/{param}/{type}")
@ResponseBody
public Object checkData(@PathVariable String param, @PathVariable Integer type, String callback) { TaotaoResult result = null; // 参数有效性校验
if (StringUtils.isBlank(param)) {
result = TaotaoResult.build(400, "校验内容不能为空");
}
if (type == null) {
result = TaotaoResult.build(400, "校验内容类型不能为空");
}
if (type != 1 && type != 2 && type != 3) {
result = TaotaoResult.build(400, "校验内容类型错误");
}
// 校验出错
if (null != result) {
if (null != callback) {
JSONPObject jsonpObject = new JSONPObject(callback, result);
return jsonpObject;
} else {
return result;
}
}
// 调用服务
try {
result = userService.checkData(param, type); } catch (Exception e) {
result = TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
} if (null != callback) {
JSONPObject jsonpObject = new JSONPObject(callback, result);
return jsonpObject;
// MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(result);
// mappingJacksonValue.setJsonpFunction(callback);
// mappingJacksonValue.setValue(callback);
// return mappingJacksonValue;
} else {
return result;
}
}

SpringMVC中JSONP的基本使用的更多相关文章

  1. SpringMvc中的数据校验

    SpringMvc中的数据校验 Hibernate校验框架中提供了很多注解的校验,如下: 注解 运行时检查 @AssertFalse 被注解的元素必须为false @AssertTrue 被注解的元素 ...

  2. 【Spring】SpringMVC中浅析Date类型数据的传递

    在控制器中加入如下代码: @InitBinder public void initBinder(ServletRequestDataBinder bin){ SimpleDateFormat sdf ...

  3. 详解SpringMVC中GET请求

    GET请求概述 GET请求,请求的数据会附加在URL之后,以?分割URL和传输数据,多个参数用&连接.URL的编码格式采用的是ASCII编码,而不是uniclde,所有的非ASCII字符都要编 ...

  4. SpringMVC中使用Interceptor拦截器

    SpringMVC 中的Interceptor 拦截器也是相当重要和相当有用的,它的主要作用是拦截用户的请求并进行相应的处理.比如通过它来进行权限验证,或者是来判断用户是否登陆,或者是像12306 那 ...

  5. 如何在springMVC 中对REST服务使用mockmvc 做测试

    如何在springMVC 中对REST服务使用mockmvc 做测试 博客分类: java 基础 springMVCmockMVC单元测试  spring 集成测试中对mock 的集成实在是太棒了!但 ...

  6. springMVC 返回类型选择 以及 SpringMVC中model,modelMap.request,session取值顺序

    springMVC 返回类型选择 以及 SpringMVC中model,modelMap.request,session取值顺序 http://www.360doc.com/content/14/03 ...

  7. SpringMVC中使用Cron表达式的定时器

    SpringMVC中使用Cron表达式的定时器 cron(定时策略)简要说明 顺序: 秒 分 时 日 月 星期 年份 (7个参数,空格隔开各个参数,年份非必须参数) 通配符: , 如果分钟位置为* 1 ...

  8. SpringMVC中使用Json传数据

    在web项目中使用Json进行数据的传输是非常常见且有用的,在这里介绍下在SpringMVC中使用Json传数据的一种方法,在我的使用中,主要包括下面四个部分(我个人喜好使用maven这类型工具进行项 ...

  9. springmvc 中controller与jsp传值

    参考:springmvc 中controller与jsp传值 springMVC:将controller中数据传递到jsp页面 jsp中,死活拿不到controller中的变量. 花了半天,网上列出各 ...

随机推荐

  1. 做错的题目——给Array附加属性

  2. discuz 3.1论坛快照被百度劫持解决方案

    最近很郁闷,遇到一个很棘手的问题.我们公司有个论坛在百度查看快照信息的时候全部都是博彩信息,但是打开却无博彩信息显示.在快照中查看是这样的 百度快照查看图: 经过思考,怀疑是网站中有网页被改动了,在某 ...

  3. (set stringstream)单词数 hdu2072

    单词数 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  4. 字节输出流 FileOutputStream

    输入和输出 : 参照物 都是java程序来参照 output 内存---->硬盘 input 持久化数据-->内存 字节流输出 定义:流按照方向可以分为输入和输出流 字节流 :可以操作任何 ...

  5. bzoj2434 fail树 + dfs序 + 树状数组

    https://www.lydsy.com/JudgeOnline/problem.php?id=2434 打字机上只有28个按键,分别印有26个小写英文字母和'B'.'P'两个字母.经阿狸研究发现, ...

  6. 20165232 预备作业3 Linux安装及学习

    java第三次预作业--Linux安装及命令入门(学习记录) 通过老师给的学习基于VirtualBox虚拟机安装Ubuntu图文教程,我在自己笔记本上安装Linux操作系统,在安装过程中我遇到一些问题 ...

  7. Hbase 1.3.0 Rsgroup

    HBase RSGroup Git环境window环境下,警用crlf自动转换git config --global core.autocrlf false protobuf环境yum install ...

  8. ORM常用字段和参数

    目录: ORM常用字段和参数

  9. css 绝对定位实现水平垂直居中

    负margin实现水平垂直居中 width: 500px; height: 500px; position: absolute; left: 50%; top :50%; margin-left: - ...

  10. Trailing slash

    Trailing Slash common case It's common for URLs with a trailing slash to indicate a directory, and t ...