Announcement Announcement Module
No announcement yet.
Why is message bundle key getting put in the URL? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is message bundle key getting put in the URL?


    I'm using Spring 3.0. After updating/adding something in the database, I want to display a success message to the user. So on my JSP, I have

    						<c:if test="${not empty statusMessageKey}">
           						<p><fmt:message key="${statusMessageKey}"/></p>
    However, no message is displaying, and instead the URL looks like "/sweeps/home?promoTypes=1&statusMessageKey=user.promotion. rule.add.success". Anyone know where I'm going wrong? Below is the method from my controller ...

        @RequestMapping(value="/sweeps/rules/form", method=RequestMethod.POST)
        public String processSubmit(UserPromotionRule userPromotionRule, BindingResult bindingResult, Model model) {
        	final boolean isUpdate = userPromotionRule.getId() != null;
        	validator.validate(userPromotionRule, bindingResult); 
        	String redirect = null;
        	if (bindingResult.hasErrors()) { 
        		redirect = "form";
        	} else { 
        		UserPromotionRule result =;
        		String statusMessageKey = isUpdate ? "user.promotion.rule.update.success" : "user.promotion.rule.add.success";
        		model.addAttribute("statusMessageKey", statusMessageKey);
        		redirect = "redirect:/../sweeps/home?promoTypes=" + userPromotionRule.getUserPromotionTypeId(); 
        	}	// if
        	return redirect;

    Thanks, - Dave

  • #2
    Use ${param.}

    Prefixing "redirect:" to the view name leads to a client side redirect and any model attributes added in the controller are put the as url parameters, since its a completely new request.

    In the JSP EL, following will give the value of the statusMessageKey parameter.

    <c:if test="${not empty param.statusMessageKey}">
    <p><fmt:message key="${param.statusMessageKey}"/></p>