Questions tagged [spring-json]
35 questions
47
votes
15 answers
Spring MVC - HttpMediaTypeNotAcceptableException
I keep getting this HttpMediaTypeNotAcceptableException error for AJAX requests when using with Spring MVC and JSON.. full stack trace of the error is..
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable…

RKodakandla
- 3,318
- 13
- 59
- 79
8
votes
3 answers
How to force Initialize a Hibernate JPA proxy to use it in a JSON call
I have a Spring 3 + JPA 2.0 application. In my @Controller I need an initialized object, but I have proxies , I need to be able to initialize it programmatically. I need functionality similar to org.hibernate.Hibernate.initialize(Object) .
Can…

pmanolov
- 623
- 1
- 6
- 19
6
votes
4 answers
Spring mappingjackson2messageconverter give null pointer exception
I'm trying to convert a java object to json format using mappingjackson2messageconvertor but looks like it is not converting to json object instead throwing nullpoint exception error. Wondering what i'm doing wrong.
I have checked one of the…

user1595858
- 3,700
- 15
- 66
- 109
4
votes
1 answer
Spring Integration transformation error with json path expression
My spring integration is trying to transform JSON message from input channel and extract a value from JSON message by providing the corresponding key. Its throwing SpelEvaluationException.
Spring Integration…

VeeAar
- 91
- 1
- 12
3
votes
1 answer
Integrating JackSon for JSON View with Spring 2.5
We are using Spring 2.5 and spring-json for JSON support. We have the below configuration in views.xml
Now, we have learnt that Spring 3.x uses JackSon API…

hop
- 2,518
- 11
- 40
- 56
3
votes
1 answer
Rest Custom HTTP Message Converter Spring Boot 1.2.3
I want to create a custom of HttpMessageConverter using Rest, Json, Spring Boot 1.2.3 and Spring 4, However my custom HTTPMessageConverter its' never called.
I have preformed the following steps :
1: Created a class that extends…

Kamal
- 1,476
- 1
- 13
- 21
3
votes
0 answers
AJAX and CSRF in Spring
I'm sending a CSRF token in an HTTP request header and in a POST hidden field to guard against CSRF attacks something like the following.
var request;
var timeout;
function insert(callback)
{
if(!request)
{
…

Tiny
- 27,221
- 105
- 339
- 599
2
votes
1 answer
spring boot with thymeleaf html table with class model array
I got this class model (I made it only 2 column),
public class DataModel {
private int id;
private String name;
public DataModel() {}
public int getId() {
return id;
}
public void setId(int id) {
this.id =…

Ricky Vene
- 105
- 1
- 11
1
vote
0 answers
Spring JS Ajax call - enum data binding failing to convert but strings working
I'm using Spring with dijit components to render an option list from an enum in my model:
…

mental_wao
- 11
- 1
- 3
1
vote
2 answers
Java Spring web - convert sub-property to object with validator
I'm using spring web with controllers services models and validation.
I have a Color object and a Color service.
@Data
public class Color {
private String name;
private long value;
private int rating;
}
In one of my controllers, I'm…

Hodor
- 13
- 2
1
vote
1 answer
Java Spring Data JPA and REST API: exclude fields of nested JSON object
Currently I'm using Spring Data JPA 2.2.1 with a Spring Boot Web 2.2.1 for a REST API service.
A getter call to /categories returns the following JSON, which in fact is the desired result:
[
{
"category1": "A",
"category2": "B",
…
user6440081
1
vote
1 answer
spring json writes more json then i want
I am using the json spring view in order to return a simple JSON object from my controller.
The problem is that its returning more data then i want. it is returning the validation errors and things inside of my model when all i am doing is this in…

mkoryak
- 57,086
- 61
- 201
- 257
1
vote
1 answer
Alternative to deprecated method ObjectMapper.setFilters()
I have the following part of code that helps me mask certain attributes of a json response,
ObjectMapper mapper = new ObjectMapper();
mapper.setFilters(new SimpleFilterProvider().addFilter("sampleFilter", new SampleFilter())
…
user7950856
1
vote
1 answer
Converting a Java class with nested array of Java classes to JSON
Is there a convenient way to convert a Java class with a nested array of Java classes into JSON? For instance I want to convert an instance f the following class to JSON:
public class Students {
private final String serial_no;
private final…

user2399453
- 2,930
- 5
- 33
- 60
1
vote
1 answer
How to add message converter to restTemplate in xml configuration
I am using restTemplate for consuming json data from remote server, and then parsing the json in my java objects using jackson. I have added required message converters to my restTemplate by java code as:
List>…

Arpan Das
- 1,015
- 3
- 24
- 57