I am working with Spring 4.0.5.RELEASE, Spring MVC through only Java Config
I have in my pom.xml the following:
&
For the audience.
The error was in the same URL.
It contains .htm
Therefore for all the developers be sure to remove it
From
@RequestMapping(value="/findallproductobycategoria.htm", method=RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Set<Producto> findAllProductoByCategoria(@RequestBody Categoria categoria){
logger.info("findAllProductoByCategoria: {}", categoria.toString());
return this.fakeMultipleRepository.findAllProductoByCategoria(categoria.getId());
}
To
@RequestMapping(value="/findallproductobycategoria", method=RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Set<Producto> findAllProductoByCategoria(@RequestBody Categoria categoria){
logger.info("findAllProductoByCategoria: {}", categoria.toString());
return this.fakeMultipleRepository.findAllProductoByCategoria(categoria.getId());
}
From:
$.ajax({
url: "/spring-utility/facturaajax/findallproductobycategoria.htm" ,
data: JSON.stringify(json),
dataType: 'json',
type: "POST",
To:
$.ajax({
url: "/spring-utility/facturaajax/findallproductobycategoria" ,
data: JSON.stringify(json),
dataType: 'json',
type: "POST",
Because I have
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
Map<String,MediaType> mediaTypes = new LinkedHashMap<>();
mediaTypes.put("json", MediaType.APPLICATION_JSON);
mediaTypes.put("xml", MediaType.APPLICATION_XML);
configurer.mediaTypes(mediaTypes);
configurer.defaultContentType(MediaType.TEXT_HTML);
}
Spring gives more preference about the URL .extension than the header content