Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:56+00:00 2026-05-23T14:24:56+00:00

I would know how works the configuration about Spring MVC rest services that returns

  • 0

I would know how works the configuration about Spring MVC rest services that returns JSON.

I have configurated the applicationContenxt.xml in this way:

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
        </list>
    </property>
</bean>
<bean id="contentNegotiatingViewResolver" class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    <property name="mediaTypes">
        <map>
            <entry key="json" value="application/json"/>
        </map>
    </property>
    <property name="defaultViews">
        <list>
            <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
        </list>
    </property>
</bean>
<bean class="com.MyController"></bean>

And this is the code of my controller:

@Controller(value="MyController")
public class MyController {
    @RequestMapping(value="/getValue", method=RequestMethod.GET)
    public ModelAndView getValue() {
        Map model = new HashMap();
        model.put("asasa", "bbbbb");
        model.put("cccc", "ddddd");
        return new ModelAndView("jsonView",model);
    }
}

I’m missing something about xml configuration or Java code? I have always error 404 while trying to invoke this resource: http://localhost:8080/fss/MyController/getValue

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:24:57+00:00Added an answer on May 23, 2026 at 2:24 pm

    Just do:

    @Controller
    public class HelloController {
    
      @RequestMapping(value="/hello", method=RequestMethod.GET)
      public @ResponseBody String hello(@RequestParam String name) {
        return "Hi " + name;
      }
    }
    

    Change the return type to an object and include jackson in the classpath for an object response.

    The request need to have a application/json header for the controller to return json.

    Check out http://blog.springsource.com/2010/01/25/ajax-simplifications-in-spring-3-0/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a C# spell check library that would underline misspelled works
I would like to know what of the many XSLT engines out there works
I would like to know exactly how the Is command works in Linux and
I would like to know how the recycle image link works, it points to
Does any one know how I would have to change the following to work
I have a question about storing site configuration data. We have a platform for
I know next-to-nothing about Java's security model, including XML configuration, policy-setting, any security framework
I would like to know, wether Server.Transfer will work in a Web Farm. Thanking
Would this work on all platforms? i know windows does \r\n, and remember hearing
I tried to solve problems from Project Euler. I know my method would work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.