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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:41:48+00:00 2026-05-19T12:41:48+00:00

Right now, my web.xml is configured in the way that Spring MVC will take

  • 0

Right now, my web.xml is configured in the way that Spring MVC will take over anything that has *.html suffix. I have a few controllers that generate the web links based on current user state.

For instance, I have the following code to determine what the “Next” button should point to:

if (nextSlide != null) {
    nextLink = String.format("/%s/module/%d/slide/%d.html", studyName, moduleId, nextSlide.getKey());
}
else {
    nextLink = String.format("/%s/module/all.html", studyName);
}

But, I don’t like this approach because I’m hardcoding the “.html” to the links here. I could certainly create a factory that generates links with “.html” suffix to hide from all the controller code, but that still requires me to hardcode “.html” once in my Java code… not too DRY.

I’m basically hoping Spring MVC has some APIs that allow me to construct the links. If these APIs don’t exist, do you hardcode the suffix in the Java code like what I do here?

  • 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-19T12:41:49+00:00Added an answer on May 19, 2026 at 12:41 pm

    There is not. Given what you currently have, you have three options. Two of these are your option, and dwb’s option. The other is to create your own taglib.

    It seems like you’re doing some kind of wizard functionality (where screen 2 is dependent on a click from screen 1). If that’s the case, I would look into Spring Webflow.

    Another possibility is to perform an AJAX callout to some sort of decision method, or you could handle this all on the client side with JavaScript.

    Also, FWIW, I don’t think coding .html is breaking DRY, but I would be concerned about maintenance in case your servlet ever matched on something other than this suffix. You could most likely do something similar to the below example by just essentially returning a new ModelAndView or redirecting to one at least:

    @RequestMapping("slide/{id}")
    public String goToSlide(@PathParam("id") String id, ModelMap model) {
        model.adAttribute("slide", slideService.findById(id));
        return "slides/slide";
    }
    
    @RequestMapping("all")
    public String getAllSlides() {
        return "slides/all";
    }
    
    @RequestMapping(value="slideshow/{id}", method=RequestMethod.GET)
    public String getSlideshow(@PathParam("id") String slideshowId, ModelMap model) {
        model.attAttribute("slideshow", slideshowService.findById(slideshowId));
        return "slides/slideshow";
    }
    
    @RequestMapping(value="slideshow", method=RequestMethod.POST)
    public String postSlideshow(@QueryParam("slideId") String slideId) {
        if(slideId != null) {
            return "slide/" + slideId;
        }
        return "redirect:all";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently stacked with the web service that im creating right now. when Testing
We are building a web based solution right now and it is almost ready
I have my core web-app code in the header right now in a tag
I am experimenting with Intraweb right now, for a few small personal-use web apps
I am tightening down my web application and I am on SQL right now.
I'm new to web development. Right now I'm working on a login feature on
I wouldn't usually bother to obfuscate a web application DLL but right now I
Here is the thing. Right now I have this e-commerce web site where people
I'm currently working on web application using VB in ASP.NET. Right now I have
I am currently working on a web-app/server in python and cherrypy. Right now, I

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.