jsp错误消息未显示

时间:2010-02-05 09:50:15

标签: java spring jsp

当我想显示错误消息但是当它通过

返回JSP页面时,在JSP上

<form:errors path="arnNumber" cssClass="error" /></span>

它给了我一个例外

  

org.springframework.context.NoSuchMessageException:   代码'ARN下未找到任何消息   号码是   required.contactUsUtil.arnNumber'for   locale'en_US'。

2 个答案:

答案 0 :(得分:0)

字面翻译,只是意味着它无法在您messageSource的{​​{1}}属性中找到与消息包中的以下密钥

ARN number is required.contactUsUtil.arnNumber
相关联的任何消息。


密钥看起来很可疑:)

答案 1 :(得分:0)

在Application context

下定义它
<bean id="responseMessageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="cacheSeconds" value="3"/>
    <property name="basename" value="classpath:response_msg" />
    <property name="defaultEncoding" value="UTF-8"/>
</bean>

在资源文件夹下定义,很容易

NO_SESSION=SESSION ERROR
NO_PHOTO=The photo with specified id couldn't find
SUCCESSFULL_CRATED_ALBUM=Album has created successfully
ASSIGNED_ALBUM_PHOTO=This photo assigned as your album photo.
SUCCESFULL_UPDATED_ALBUM=Album has updated successfully
SUCCESFULL_UPDATED_PHOTO=Photo has updated successfully
SUCCESFULL_CRATED_IMAGE_DIRECTORY=Image directories created successfully