`
wbj0110
  • 浏览: 1550643 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

passing JSON data to a Spring MVC controller

阅读更多

Add the following dependencies

   <dependency>

        <groupId>org.codehaus.jackson</groupId>

        <artifactId>jackson-mapper-asl</artifactId>

        <version>1.9.7</version>

   </dependency>

   <dependency> 

        <groupId>org.codehaus.jackson</groupId>

        <artifactId>jackson-core-asl</artifactId>

        <version>1.9.7</version>

    </dependency>

add request as follows

   $.ajax({ 

                url:urlName,

                type:"POST", 

                contentType: "application/json; charset=utf-8",

                data: jsonString, //Stringified Json Object

                async: false,    //Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation

                cache: false,    //This will force requested pages not to be cached by the browser  

                processData:false, //To avoid making query String instead of JSON

                success: function(resposeJsonObject){

        }});

CONTROLLER SIDE

  @RequestMapping(value = urlPattern , method = RequestMethod.POST)

   public @ResponseBody Person save(@RequestBody Person jsonString) {

     Person person=personService.savedata(jsonString);

    return person;

}

@RequestBody -Covert Json object to java

@ResponseBody-convert Java object to json

分享到:
评论

相关推荐

    Clustering by Passing Messages Between Data Points

    Clustering data by identifying a subset of representative examples is important for processing sensory signals and detecting patterns in data. Such “exemplars” can be found by randomly choosing an ...

    Manning.Spring.in.Action.4th.Edition.2014.11.epub

    10.1.1. Getting to know Spring’s data-access exception hierarchy 10.1.2. Templating data access 10.2. Configuring a data source 10.2.1. Using JNDI data sources 10.2.2. Using a pooled data source ...

    JavaScript and JSON Essentials2018

    Chapter 1, Getting Started with JSON, introduces the audience to JSON, discusses the history of JSON along with how it works and stores itself in memory. The chapter also outlines the popular ...

    Pivotal Certified Professional Spring Developer Exam(Apress,2016)

    Passing the exam demonstrates your understanding of Spring and validates your familiarity with: container-basics, aspect oriented programming (AOP), data access and transactions, Spring Security, ...

    Designing Data Tier Components and Passing Data Through Tiers

    When designing a distributed application, you need to decide how to access and represent the business data associated with your application. This document provides guidance to help you choose the most...

    Passing Binary Data in COM在COM中传递二进制数据

    Passing Binary Data in COM在COM中传递二进制数据

    外文翻译 stus MVC

    Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. Struts is an MVC implementation that uses Servlets 2.2 and ...

    Learning.to.Love.Data.Science.1491936584

    Until recently, many people thought big data was a passing fad. "Data science" was an enigmatic term. Today, big data is taken seriously, and data science is considered downright sexy. With this ...

    Exam Ref 70-761 Querying Data with Transact-SQL

    Passing this exam earns you credit toward a Microsoft Certified Solutions Associate (MCSA) certification that demonstrates your mastery of essential skills for building and implementing on-premises ...

    Passing parameters with data reports. I have set two paramet

    Passing parameters with data reports. I have set two parameters and passed them during run time.Open with VB6.

    pro spring 2.5

    t was with a heavy heart that I made the decision not to participate in writing Pro Spring 2.5. I am deeply thankful that Jan was around to pick up this book and run with it. Pro Spring has been a big...

    Passing arguments to Python functions

    深入讲解了python函数传参的原理,值得一看

    Json_decode 解析json字符串为NULL的解决方法(必看)

    一般会反应是少了一个参数“true”,但是回去看就是 json_decode($data,true); 那怎么还会是NULL呢?难道是编码,不会啊,接收后直接打印是一个完整json字符串的形式,在网上json解析网站,也是可以正常解析的。 那...

    AP聚类_Clustering by Passing Messages Between Data Points1

    Brendan J. Frey* and Delbert DueckClustering data by identifying a subset of rep

    Linear Network Coding 线性网络编码

    Among the simples coding schemes is linear coding, which regards a block of data as vector over a certain base field and allows a node to apply a linear ansformation to a vector before passing it on....

    S7A驱动720版本

    - From the S7A power tool it wasn't possible to open the online help file. Now it can be opened and also the context-sensitive help works properly. - When the signal conditioning function "S&M" ...

    Parallel Computer Architecture - A Hardware Software Approach

    This book explains the forces behind this convergence of shared-memory, message-passing, data parallel, and data-driven computing architectures. It then examines the design issues that are critical ...

    html5的data-role的属性

    html5的data-role的属性,The jQuery Mobile ... To avoid naming conflicts with other plugins or frameworks that also use data- attributes, set a custom namespace by modifying the ns global option。

    reactnd-passing-data2

    要将现有项目更新为新版本的react-scripts ,请 ,找到当前使用的版本(如果不确定,请检查此文件夹中的package.json ),然后为较新的版本应用迁移说明版本。 在大多数情况下,package.json的

Global site tag (gtag.js) - Google Analytics