valuestack

How to use OGNL index reference operator

戏子无情 提交于 2019-12-02 08:35:30
问题 Working with OGNL you can reference action context objects like #application , #session , #root , #action , #request , #parameters , #attr , and the action context with #context . The framework sets the OGNL context to be our ActionContext, and the value stack to be the OGNL root object. And OGNL uses [] as index reference to access an object properties. For example if the object foo has a property bar then it can access like foo.bar or foo['bar'] . It also works if foo is a map and bar is a

How to use OGNL index reference operator

半腔热情 提交于 2019-12-02 08:03:33
Working with OGNL you can reference action context objects like #application , #session , #root , #action , #request , #parameters , #attr , and the action context with #context . The framework sets the OGNL context to be our ActionContext, and the value stack to be the OGNL root object. And OGNL uses [] as index reference to access an object properties. For example if the object foo has a property bar then it can access like foo.bar or foo['bar'] . It also works if foo is a map and bar is a key. Now, I want to put a variable and a value to the value stack context like that <s:set var="bar"

Pass Arraylist from Java class and fetch it in JSP page In Struts 2

杀马特。学长 韩版系。学妹 提交于 2019-12-02 07:42:28
I am trying to get ArrayList in JSP page passed from java class. But eventually I didn't succeed. Here is what I have done. Here is my POJO class: public class Coordinates { private double latitude; private double longitude; public double getLatitude() { return latitude; } public void setLatitude(double latitude) { this.latitude = latitude; } public double getLongitude() { return longitude; } public void setLongitude(double longitude) { this.longitude = longitude; } } And this one is Java class where I write business logic: public class Leverage extends ActionSupport{ List<Coordinates> mylist

SSH框架中不为人知的细节(一)

跟風遠走 提交于 2019-12-01 12:48:58
一、 ModelDriven的运行机制 大家都知道前台表单数据向后台传递的时候,调用的Action会实现ModelDriven接口。伪码如下: VO伪码: public class User { private String userName; private String password; //setter and getter //.... } Action伪码: public class UserAction implements ModelDriven { private User user = new User(); public String addUser() { //相应的业务逻辑 } @Override public Object getModel() { return user; } } JSP伪码: <form action="xxx/user-add.action" method="post"> username:<input type="text" name="username" /> password:<input type="text" name="password" /> <input type="submit" name="submit" value="添加" /> </form> 上面的代码相信大家非常熟悉

Struts2-Value Stack浅析

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:48:32
Value Stack的作用: 1. 可以作为一个数据中转站 2. 用于在前台 - 后台之间传递数据,最典型的做法就是 struts2 标签也 ognl 表达式的结合。我用得最多的就是数据回显。 Value Stack的生命周期: 在 struts-default.xml 文件中决定了在 web 容器启动时将会创建 OgnlValueStackFactory 对象,该对象实现了 ValueStackFactory 接口,负责 ValueStack 的创建工作。 ValueStack 的生命周期是随着 request 的创建而创建,随 request 的销毁而销毁。具体可见源代码: 在 PrepareOperations 类的 createActionContext 中有 至于清理工作, struts 统一放在了 PrepareOperations 类的 cleanupRequest 方法中。 Value Stack结构: 主要看 OgnlValueStack 类,此类实现了 ValueStack 接口。 在 OgnlValueStack 中有两个至关重要的东西, ,简称“对象栈 ” 和 “Map 栈 ” 。 CompoundRoot: CompoundRoot 继承了 ArrayList 类,即是一个 List 集合,详见源码 CompoundRoot 类。 Context: 而

Parameter Passing for statically included page in Struts 2

三世轮回 提交于 2019-12-01 11:59:12
I have a parent file where my JSP is statically included. <%@include file="test.jsp" %> In the included file I want to access the variable of parent JSP using Struts2 tag. Please let me know if it is possible or should I go for dynamic include. You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them. Besides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest one is that properties are no longer accessed with a

Parameter Passing for statically included page in Struts 2

大憨熊 提交于 2019-12-01 11:40:20
问题 I have a parent file where my JSP is statically included. <%@include file="test.jsp" %> In the included file I want to access the variable of parent JSP using Struts2 tag. Please let me know if it is possible or should I go for dynamic include. 回答1: You can't access the variable but you can access the variable from the the value stack using OGNL. See OGNL Basics to learn more about variables in Struts and how to use them. Besides the examples and descriptions given above, there are a few

Struts 2 calling static method when struts.ognl.allowStaticMethodAccess is false

痴心易碎 提交于 2019-11-30 20:36:06
问题 The struts 2 set the struts.ognl.allowStaticMethodAccess to false , for security issues. The static method invocation may be useful in some cases for example when dealing with expression base validators Struts 2 using StringUtils in validator expersions. One way to solve this problem is to define a helper method in the action, for example, if we want to use Math class we should add below: public double randomMath(){ return Math.random(); } public double asinMath(double a){ return Math.asin(a)

Calling function of Action class in Jsp Struts2

好久不见. 提交于 2019-11-30 14:23:48
问题 I have a little scenario. I have two POJO classes and two tables User and Domain (same name for tables). Every user will belong to one and only one domain. I have two Action classes one is UsersManagemntAction and other is DomainsManagementAaction . I use UsersManagemntAction to perform CRUD operations that are related to users. In my User class I have an attribute domainId . This attribute will contain the id of Domain to which user belong. My problem is that I when I show user information

Calling function of Action class in Jsp Struts2

♀尐吖头ヾ 提交于 2019-11-30 10:24:56
I have a little scenario. I have two POJO classes and two tables User and Domain (same name for tables). Every user will belong to one and only one domain. I have two Action classes one is UsersManagemntAction and other is DomainsManagementAaction . I use UsersManagemntAction to perform CRUD operations that are related to users. In my User class I have an attribute domainId . This attribute will contain the id of Domain to which user belong. My problem is that I when I show user information in jsp page I show the domainId with the users information. This is because user object will have the