`
wbj0110
  • 浏览: 1602426 次
  • 性别: 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, ...

    外文翻译 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 ...

    Passing arguments to Python functions

    在这个例子中,`a` 是一个位置参数,调用函数时需要提供一个值给 `a`。如果提供的参数数量与定义时的数量不符,则会引发错误。 **示例:** ```python # 正确的调用 nostar(1) # 错误的调用 nostar(1, 2, 3) # ...

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

    在COM(Component Object Model)中,传递二进制数据是一个常见的需求,特别是在处理图像、音频、文件等非结构化数据时。... 首先,让我们来看看`BufferVariant.h`这个文件名,它暗示了一个使用了`VARIANT`类型的缓冲...

    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...

    Designing Data Tier Components and Passing Data Through Tiers

    - **使用LINQ**:通过Linq to SQL或Linq to Entities可以更加简洁地处理数据查询和更新操作。 #### 十、结合使用存储过程 存储过程是一种预编译的SQL脚本,可以在数据库端执行。结合使用存储过程和数据访问逻辑...

    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 ...

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

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

    asp.net mvc 分部视图的基本使用

    3. **传递参数给分部视图(Passing Parameters to a Partial View)** 当需要根据某些条件改变分部视图的行为时,可以向分部视图传递参数。这可以通过两种方式实现:在动作方法中设置模型,或者在`@Html.Partial`或...

    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 ...

    16.spring与springmvc常见面试题.docx

    答:Spring 框架是一个一站式(full-stack 全栈式)框架,提供了从表现层-springMVC 到业务层-spring 再到持久层-springdata 的一套完整的解决方案。我们在项目中可以只使用 Spring 一个框架,它就可以提供表现层的 ...

    reactnd-passing-data2

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

Global site tag (gtag.js) - Google Analytics