<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