开发者

Spring MVC : showing a link in the error message

I have the following snippet of code in the Validator which basically is used to show an error message. In the error message 开发者_运维问答I would like to show a link by sending it as a parameter in the error message.

if (user != null && formData.getUserId()== null) {          
    errors.rejectValue("email", "email.already.exists",new Object[]{"Link "},null);
    return;
}

I am unable to get the desired error message on the JSP page . The error is rendered like a string and is not converted to HTML code. Please help.

Thank you Manu


<form:errors> has an escapeHtml attribute:

<form:errors escapeHtml = "false" ... />

Note, however, that this may cause undesired behaviour if other error messages displayed by this tag should be escaped.


The attribute is now htmlEscape. See this for reference.

So, if you use <form:errors htmlEscape="false" ... /> then you can have html in the error.


The error variable should only be a string. In your JSP, enclose that string with whatever HTML markup you would like.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜