in Education by
I'm trying to use MappingJacksonJsonView with Spring 3.0, without success. I don't know what I'm doing wrong, I think the problem is that I don't know how to tell to use the MappingJacksonJsonView to render a request. I tried to use the same name for view name and bean name of MappingJacksonView, but didn't work. I built a sample test application here: https://github.com/stivlo/restjson In web.xml I've defined ContextLoaderListener and the mapping for dispatcherServlet. In servlet-context.xml I've added and In org.obliquid.restjson.web.ToDoList.java I set the logical view name as jsonView. However, instead of using MappingJacksonJsonView, it looks for a JSP file, according to my JSP mapping. message /restjson/WEB-INF/jsp/jsonView.jsp description The requested resource (/restjson/WEB-INF/jsp/jsonView.jsp) is not available. What should I change to use MappingJacksonJsonView as a renderer? UPDATE 1: In following tests I've found that if I add the following to my servlet-context.xml, JSON rendering works, but my other view, rendered as JSP (home) is not working anymore. <!-- Resolve views based on string names --> UPDATE 2: I removed the BeanNameViewResolver and changed my ToDoList.java to return directly the Collection to be converted in JSON, instead of ModelAndView, with a @ResponseBody annotation, as follows: @RequestMapping("/toDoList") public @ResponseBody List test() { List toDoList = new ArrayList(); toDoList.add(new ToDoItem(1, "First thing, first")); toDoList.add(new ToDoItem(1, "After that, do the second task")); return toDoList; } In this way it works. Even though the mapping is even more "magical". It makes me wonder, if a similar renderer exists for XML for instance, how does Spring know which renderer to pick? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Spring will use Accept header sent by the client to return most appropriate view. Here you will find my complete Spring MVC application that returns both JSON and XML. As you can see, I only needed: I also used the same annotations: @RequestMapping to map request to a method and @ResponseBody to tell Spring that what I am returning from the controller is the actual response. It might however need some tweaking/formatting, and here Spring takes care of marshalling your object into most appropriate type like JSON.

Related questions

0 votes
    I have an Enum package com.javarnd.bbms.enums; public enum BloodTypeEnum { A_PLUS(1, "A+"), ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
0 votes
    I would like some help to adjust the output called adjusted that I generate. My idea is to optimize somehow to ... dplyr) library(tidyr) library(lubridate) library(data.table) df1...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I would like some help to adjust the output called adjusted that I generate. My idea is to optimize somehow to ... dplyr) library(tidyr) library(lubridate) library(data.table) df1...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I think I shall reframe my question from Where should you use BlockingQueue Implementations instead of Simple Queue ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    What does javascript use instead of == and !=? (a) It uses bitwise checking (b) It uses === ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which method to use while working with XML fragments, instead of XML()? (a) XMLInterface() (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    ETACS use ___________ instead of SID (system identification number). (a) Area identification number (b) Analog ... (c) Digital identification number (d) Dual identification number...
asked Oct 4, 2021 in Technology by JackTerrance
0 votes
    Can we use JSON instead of YAML while developing docker-compose file in Docker?...
asked Jun 21, 2021 in Technology by JackTerrance
0 votes
    When might you use a CFArray/Dictionary instead of a NSArray/Dictionary?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    I have designing the TabMenu Like following $(function() { $('#container-1').tabs(); $(' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I have designing the TabMenu Like following $(function() { $('#container-1').tabs(); $(' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I was trying to write a quick-and-dirty script to generate plots easily. For that, I was using the following code ( ... do I do that? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I am confused about the usage of string.join(list) instead of list.join(string), for instance see this code: ... reason behind this? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    While I try to answer any question in brainly app, the cursor is moving from right to left instead of moving ... Why does it happen? Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
...