将Html代码从Controller传递给JSP

时间:2012-12-26 08:44:17

标签: javascript jsp spring-mvc uiviewcontroller validation

我想将html数据从Controller传递给JSP。

我正在使用Spring MVC'Spring Validator'填充JSP上的消息:

@Override
    public void validate(Object target, Errors errors) {
//Some processing     
errors.rejectValue("fileData", "errors.csi.invalidurl", new Object[] { url }, null);
}

message.properties

errors.csi.invalidurl=File contained invalid URLs. Please find list of invalid URLs <a href="{0}"> here</a>.

对应的JSP是:

<div class="row">
<label for="upload-file"><spring:message code="csi.label.uploadfile"/></label><form:input path="fileData" type="file"/>
<form:errors path="fileData" cssClass="error"/>
</div>

我能够传递文本数据但无法传递href链接。怎么可能呢?

我试过

String url = "javascript:getImageValidationPresignedURLForDownload('8162')"; to be passed as text data but it is displayed as text.

URLs <a href="javascript:getImageValidationPresignedURLForDownload('8162')"> here</a>.

我做错了什么?怎么可能呢?

谢谢,

1 个答案:

答案 0 :(得分:1)

尝试

<form:errors path="fileData" cssClass="error" htmlEscape="false" />