Accessing action instance variables and model-driven bean variable values in JSP

纵饮孤独 提交于 2019-12-05 17:19:54

When both your model (on top of the stack) and your action (generally the item below the model) have properties of the same name you can disambiguate using either the #action value stack context variable, or by directly accessing the stack (bad idea).

<!-- Access action properties directly: -->
<s:property value="%{searchKey}" />          <!-- Model; top of stack.       -->
<s:property value="%{#action.searchKey}" />  <!-- Action; accessed directly. -->

<!-- Hope the stack never changes: -->
<s:property value="%{[0].searchKey}" />  <!-- Model;  top of stack.   -->
<s:property value="%{[1].searchKey}" />  <!-- Action; next stack pos. -->
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!