Spring Framework

Dynamic URLs should be easier to work worth/Add a new type of class that can be passed into @RequestMapping methods

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.5 final
  • Fix Version/s: None
  • Component/s: SpringWEB
  • Description:
    Hide

    Suppose you have the following method:

    @RequestMapping("/post/*/")
    public String showPost(Map map) {

    }

    Now, if I wanted to have pretty urls, such as: /post/welcome-to-the-site/, I could do this by adding HttpServletRequest and doing some regex and pulling this data out myself. However one of the things I love about Spring is it allows me to write code thats REALLY easy to unit test and adding an HttpServletRequest ruins that.

    Simply by noticing that there are '*' in the url, it should be possible to have a class such as RequestParts (or even a string array), that tells me that the 1st part is "welcome-to-the-site".

    In this manner, the signature could be:

    public String showPost(Map map, RequestParts rp) {
    if (rp.hasParts()) {
    // Load up rp.getPart(0);
    }
    else {
    // Show an archive page
    }
    }

    This would obviously work very well with a String array but might be ambiguous from @RequestParam, which is why a simple class could handle this.

    Show
    Suppose you have the following method: @RequestMapping("/post/*/") public String showPost(Map map) { } Now, if I wanted to have pretty urls, such as: /post/welcome-to-the-site/, I could do this by adding HttpServletRequest and doing some regex and pulling this data out myself. However one of the things I love about Spring is it allows me to write code thats REALLY easy to unit test and adding an HttpServletRequest ruins that. Simply by noticing that there are '*' in the url, it should be possible to have a class such as RequestParts (or even a string array), that tells me that the 1st part is "welcome-to-the-site". In this manner, the signature could be: public String showPost(Map map, RequestParts rp) { if (rp.hasParts()) { // Load up rp.getPart(0); } else { // Show an archive page } } This would obviously work very well with a String array but might be ambiguous from @RequestParam, which is why a simple class could handle this.

Activity

People

  • Assignee:
    Unassigned
    Reporter:
    Eric Anderson
  • Votes:
    4
    Watchers:
    0

Dates

  • Created:
    11/Feb/08 7:31 PM
    Updated:
    11/Feb/08 7:31 PM

Time Tracking

Estimated:
0.5d
Original Estimate - 0.5d
Remaining:
0.5d
Remaining Estimate - 0.5d
Logged:
Not Specified
Time Spent - Not Specified