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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:54:28+00:00 2026-05-20T07:54:28+00:00

I have read quite a few posts on ViewResolvers in Spring and I still

  • 0

I have read quite a few posts on ViewResolvers in Spring and I still have a question. I have a DispatcherServlet named dispatcher in my deployment descriptor and it maps “/” all URLs to view resolvers in dispatcher-servlet.xml. I have only one right now.

<bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/jsp/"
      p:suffix=".jsp"/>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>
</web-app>

And a controller:

@Controller
public class ItemsController {

@RequestMapping("/service")
public String service()
{
    System.out.println("From ItemsController...");
    return "service";
}

@RequestMapping("/")
public String home()
{
    System.out.println("From ItemsController...");
    return "index";
}
}

So jspViewResolver returns, in case /service is requested, “WEB-INF/jsp/service.jsp”. That’s fine. But if I want to map requests to html or xhtml files. What need I do? Add another dispatcher? Please, help me out here. Thank you so much in advance.

  • 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-20T07:54:29+00:00Added an answer on May 20, 2026 at 7:54 am

    See section 15.5.2. Chaining ViewResolvers of the Spring documentation. This allows you to use multiple InternalResourceViewResolver instances.


    You can also add other view resolvers to your applicationContext, e.g.,

    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
    <bean id="someView" class="....."/>
    

    Then in your annotated controller, when you return the string "someView" the bean with the same id will be used as your view instead of your jsp resolver. When names are conflicting you have to use the order property to set which resolver gets precedence.

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

Sidebar

Related Questions

I have read quite a few posts on SO and around the web of
I have read quite a few posts here for matching nested braces in Ruby
I've read quite a few posts that are very similar to the question I'm
I have read quite a few selcet+update questions in here but cannot understand how
I have read this question but it's not quite what I was looking for.
I've read through quite a few of posts, but none seem to do just
There is a question that bothers me for quite some time. I have read
I have read quite a few different methods of having html checkboxes get posted
OK, I've read quite a few things about PostgresSQL and it seems to have
I'm a beginner at Andengine, but I have read quite a lot of tutorials

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.