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

  • SEARCH
  • Home
  • 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 7445253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:46:32+00:00 2026-05-29T11:46:32+00:00

is it possible to use Spring 3.1 MVC without using a view resolver? The

  • 0

is it possible to use Spring 3.1 MVC without using a view resolver?

The reason why i ask is because i simply want to build and create a Web service, not a Website so i do not need to render any JSP or html pages at all. I want to build a RESTful Web service using Spring 3.1.

Is this possible?

this is how my servlett looks like which is taken from a tutorial:

Here is my mvc-config.xml

Here is my Web.xml

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <servlet>
        <servlet-name>FreedomSpring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>FreedomSpring</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>


    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>

        </param-value>
    </context-param>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.xml</param-value>
    </context-param>

    <welcome-file-list>
        <welcome-file>
      index.jsp
    </welcome-file>
    </welcome-file-list>

    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

</web-app>

And here is my controller java class that simply want to return a String from a specific http REST request and not a “ModelAndView” object so to speak

  package com.jr.freedom.controllers;

    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;

    @Controller
    public class Hello {

        @RequestMapping(value = "/hello", method = RequestMethod.GET)
        public String helloWorldInJson() {

            return "hello";
        }
    }

Also, How can i capture a requests Parameters that a client may send me? is that possible using springs annototations? i know that i can in previous Spring 2.x use HttpServletRequest and HttpServletResponse to get any parameters sent from a client and also return a object back to the user as well such as a JSON object.

i am just looking for a simple example that does this:

  1. Get parameters and possibly HTTP headers from a clients Request on my controller class and map them to some Java object “example, a client sends me details of a new user object registering to my backend service(username, password etc etc) and i want to be able to map this to my Java class Called User”

  2. Return a response of any kind of object such as a String, json or xml data to a client.

Im quite new to Spring 3.0. i did a bit of work on Spring 2.0 long ago but annotations seems the way to go now and do not know how to do it via annotations.

Thanks

Also, To execute the above controller method of helloWorldInJson() do i simply call http://localhost/FreedomSpring/hello ?

  • 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-29T11:46:33+00:00Added an answer on May 29, 2026 at 11:46 am

    You generally use @ResponseBody for this.

    See 16.3.3.5 Mapping the response body with the @ResponseBody annotation.

    This bypasses the view resolver stuff altogether.

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

Sidebar

Related Questions

I'm using Spring MVC, and I was wondering if it's possible to use methods
I want to build an MVC app using Spring (first timer here). As such
In a java web application (servlets/spring mvc), using tomcat, is it possible to run
I'm using Spring MVC (3.0) with annotation-driven controllers. I would like to create REST-ful
I wanted to use Spring MVC hidden tag in below code. Is this possible
Is it possible to use a Spring container for DI from inside Eclipse plugins?
Is it possible to use Java FutureTask with a Spring TaskExecutor to get a
I've implemented a ReloadableResourceBundleMessageSource in my Spring MVC application which I use to display
I'm looking to create a new app from scratch and will probably use Spring
In my Spring MVC webapplication I want to mix xml based configuration with annotations:

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.