struts2 s:text 标签取值范围问题

<s:text name="name"></s:text>

维护一个已有项目

使用该标签读取值时出现问题,会有请求数据串通的问题,B请求会访问到A请求设置的数据。貌似是全局变量的样子。


查看官方说明:

Render a I18n text message.

The message must be in a resource bundle with the same name as the action that it is associated with. In practice this means that you should create a properties file in the same package as your Java class with the same name as your class, but with .properties extension.

If the named message is not found in a property file, then the body of the tag will be used as default message. If no body is used, then the stack can be searched, and if a value is returned, it will written to the output. If no value is found on the stack, the key of the message will be written out.

For more details on using resource bundles with Struts 2 read the localization guide.

开不全懂,大概意思取值层次是
1.从国际化资源(properties文件)中读取name一样的值
2.如果找不到name一样的,取默认值
3.从value stack中取值
4.都没找到,输出name值

=====================================================
分析程序:
检查资源文件没有该name,也没有设置默认值。
输出时候有时候是name值,有时候是其它信息,那么就是value stack会赋值
寻找程序代码最后在struts一个exceptionhandler中有设置该值

解决方案:
不用该标签,直接request中存取值

参考:
https://struts.apache.org/tag-developers/text-tag.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值