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 6214509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:53:25+00:00 2026-05-24T06:53:25+00:00

I am working on an app which provides views for some service and acts

  • 0

I am working on an app which provides views for some service and acts as web service for others.

In controller i have mapped ‘/’ to a view and when the app starts this view is shown.
Now when i am trying to use view resolver like this

<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">  
<property name="mediaTypes">
    <map>
        <entry key="html" value="text/html" />
        <entry key="xml" value="application/xml" />
       </map>
</property>
<property name="defaultViews">
    <list>
    <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
    <bean class="org.springframework.web.servlet.view.xml.MarshallingView">
         <constructor-arg>
        <bean class="org.springframework.oxm.xstream.XStreamMarshaller"
            p:autodetectAnnotations="false" />
              </constructor-arg>
    </bean>
    </list>
    </property>
<property name="viewResolvers">
    <list>
        <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
    </list>
    </property>  


    </bean>
    <bean id="jspView" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
    </bean>

But problem is now everything is coming in xml format. So when i start the application
the first page by default comes in xml format but i want a view.

  • 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-24T06:53:26+00:00Added an answer on May 24, 2026 at 6:53 am

    By default, ContentNegotiatingViewResolver uses the HTTP Accept request header to decide which view to render. It would only send back an XML view if the client indicated in that header that it could handle the application/xml content-type, which some browsers do.

    If the browser indicates that it can accept HTML and XML, then it’s unpredictable as to which you’ll get back. In the absense of any other information, Spring has no way to decide which one you want.

    If your URL path is just /, then you’re giving it no useful information other than what the browser sends by default.

    ContentNegotiatingViewResolver can be reconfigured to use a file extension in the URL to decide which view to resolve, by setting the favorPathExtension property to true. This will, for example, response to request for /blah.xml with XML, taking precedence over the Accept header.

    ContentNegotiatingViewResolver has a few other options, I suggest reading the javadoc carefully.

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

Sidebar

Related Questions

I am working on an app which calls a rest web service. Sometimes the
I am working on a app which requires me to store some directions for
I am working on an app which needs a very simple progress view .What
I am working on an app which shall log in to a web site
I have made an android app which working fine. I implemented the Login functionality
I'm working on an app in which i have to detect left eye, right
I have a very simple web part. I have a single grid view, which
Am working on some application. However, i have finished two modules which invoke the
I'm working on a web app which is heavy on the client side, which
I'm working on the app which should download some data form server (done) and

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.