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

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

    Hi,

    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

    Code:
    						<c:if test="${not empty statusMessageKey}">
           						<p><fmt:message key="${statusMessageKey}"/></p>
    						</c:if>
    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 ...

    Code:
        @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 = userPromotionRuleDao.save(userPromotionRule);
        		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>
    </c:if>

    Comment

    Working...
    X