解决方案 »
- RMI,RPC,JAX-RPC,JAX-WS,CORBA的概念理解?
- eclipse中js文件中方法提示没有定义,但在另一个工程中却可以找到
- ssh怎么将本地文件,如excel,txt文件数据上传到mysql数据库
- SPRING连续请求的问题,请高手看看
- EJB 远程调用疑惑,(进来就有分)~
- 请问:哪里有现成的将word转换成txt文件的api
- 我是这样配置tomcat5的,但是不能用啊。请帮助我!!!
- 怎么查询CMP实体bean的内部sql啊???
- 各位老大:IIS如何与WEBLOGIC整合发布jsp!急急急
- 灵异事件!我的用DTO&SESSION FACADE WIZARD生成的Remove方法竟然报错
- jsp嵌套iframe的问题
- tomcat 解析 jsp 页面排版紊乱
EL表达式,比如${username},相当于request.getParameter(username),然后你就去理解request什么意思就可以了。
我们知道el表达式取request范围的值就是调用request.getAttribute(String s);
一下这段是struts2的org.apache.struts2.dispatcher.StrutsRequestWrapper对getAttribute方法重写的源码部分public Object getAttribute(String s) {
if (s != null && s.startsWith("javax.servlet")) {
//如果是${requestScope.javax.servlet.属性名的}就直接去request里面取值
return super.getAttribute(s);
}
//关键在下面,先从request里面取值取不到时就从值栈里面取值,所以就可以解释楼主这个为啥也能取到值了
ActionContext ctx = ActionContext.getContext();
Object attribute = super.getAttribute(s);
if (ctx != null) {
if (attribute == null) {
boolean alreadyIn = false;
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
if (b != null) {
alreadyIn = b.booleanValue();
}
if (!alreadyIn && s.indexOf("#") == -1) {
try {
// If not found, then try the ValueStack
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
ValueStack stack = ctx.getValueStack();
if (stack != null) {
attribute = stack.findValue(s);
}
} finally {
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
}
}
}
}
return attribute;
}