在页面显示Struts2提供的拦截器显示拦截成功的提示信息的步骤

来源:互联网 发布:不喝牛奶 知乎 编辑:程序博客网 时间:2024/04/30 13:26

1.在需要显示提示信息的界面一如标签库:<%@ taglib prefix="s" uri="/struts-tags" %>。

2.在这个页面中需要显示提示信心的地方加上<s:fielderror></s:fielderror>标签。

3.在src目录下建一个properties文件,文件名为XXXX_zh.properties

4.在struts.xml配置文件中加上常量配置<constant name="struts.custom.i18n.resources" value="XXXX"></constant>(XXXX和步骤3中的XXXX要一样,这样才能找的properties文件);

5.到struts和核心包struts2-core-2.5.2.jar下面找org.apache.struts2/org/apache/struts2/struts-messages_en.properties在这个properties文件里面找你所用的拦截器所对应的键

struts.messages.invalid.token=The form has already been processed or no token was supplied, please try again.
struts.internal.invalid.token=Form token {0} does not match the session token {1}.

struts.messages.bypass.request=Bypassing {0}/{1}
struts.messages.current.file=File {0} {1} {2} {3}
struts.messages.invalid.file=Could not find a Filename for {0}. Verify that a valid file was submitted.
struts.messages.invalid.content.type=Could not find a Content-Type for {0}. Verify that a valid file was submitted.
struts.messages.removing.file=Removing file {0} {1}
struts.messages.error.uploading=Error uploading: {0}
struts.messages.error.file.too.large=The file is to large to be uploaded: {0} "{1}" "{2}" {3}
struts.messages.error.content.type.not.allowed=Content-Type not allowed: {0} "{1}" "{2}" {3}
struts.messages.error.file.extension.not.allowed=File extension not allowed: {0} "{1}" "{2}" {3}

# dedicated messages used to handle various problems with file upload - check {@link JakartaMultiPartRequest#parse(HttpServletRequest, String)}
struts.messages.upload.error.SizeLimitExceededException=Request exceeded allowed size limit! Max size allowed is: {0} but request was: {1}!
struts.messages.upload.error.IOException=Error uploading: {0}!

devmode.notification=Developer Notification (set struts.devMode to false to disable this message):\n{0}

struts.exception.missing-package-action.with-context = There is no Action mapped for namespace [{0}] and action name [{1}] associated with context path [{2}].
6.找到你所用的拦截器对应的键到复制到之前的src目录下的XXXX_zh.properties值随便写 写成你想要显示的字符语句


1 0
原创粉丝点击