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

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值