在Action定义一个私有属性并设置set get方法:
private String hello="hello silenceper!";
public void setHello(String hello){
this.hello=hello;
}
public String getHello(){
return hello;
}
可以在jsp页面中通过EL表达式和struts2标签来获取属性的值:
或者
${requestScope.hello}
但是如果设置属性为public 并且 不设置set get方法的话,还是可以通过上面两中方法来获取。
这是为什么?
还有就是属性怎么到requestScope中去了?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师