valuestack

Understanding OGNL expressions in Struts2

大憨熊 提交于 2019-12-08 07:24:50
问题 The following code displays links using <s:a> of Struts starting from 1 to 10. <s:set var="currentPage" value="2"/> <s:set var="begin" value="1"/> <s:set var="end" value="10"/> <s:iterator begin="%{begin}" end="%{end}" step="1" var="row" status="loop"> <s:if test="%{#currentPage eq #row}"> <!--???--> <span><s:property value="%{#row}"/></span> </s:if> <s:else> <s:url id="pageURL" action="someAction" escapeAmp="false"> <s:param name="currentPage" value="%{row}"/> </s:url> <s:a href="%{pageURL}"

Why can't I change the valueStack of Struts2?

雨燕双飞 提交于 2019-12-08 03:26:15
问题 I do some operation of Struts2's value stack in an interceptor,code like this: public String intercept(ActionInvocation actionInvocation) throws Exception { String invokeRes = actionInvocation.invoke(); ValueStack valueStack = actionInvocation.getStack(); List<Object> shouldCheckFieldValues = Lists.newArrayList(); List<String> keywords = Lists.newArrayList("哈哈", "头部", "测试"); RegexKeywordFilter filter = new RegexKeywordFilter(); filter.add(keywords); filter.compile(); final ReplaceStrategy

How data travels in Struts2?

跟風遠走 提交于 2019-12-07 18:23:38
问题 I am trying to understand the path data takes within Struts2, how is data placed on the ValueStack? How can I find out which object is currently present in the ValueStack? What other data can I access from different scopes application, session, request, page? How to decide the scopes my variables should have? 回答1: That's a lot of questions. The value stack is just a data structure, sort of a combination of a map and stack. Named objects (accessed via the # tag in OGNL) are in the map (like

Struts 2 using StringUtils in validator expersions

怎甘沉沦 提交于 2019-12-06 22:50:34
We are using Struts 2 validators @FieldExpressionValidator and @ExpressionValidator . These validators check on OGNL expression. There are lots of cases where we deal with Strings in these expressions. expression="(captcha=='' && captcha== null || ....) We find it is very useful if we can use StringUtils ( isEmpty ,trimToEmpty,... ) here. As we set the struts.ognl.allowStaticMethodAccess to false, for security issues, we tried to solve it by adding this getter to action public StringUtils getStringUtils(){ return new StringUtils(); } and then stringUtils.isEmpty(captcha) in the expression. But

Retrieving values from list in execute() method

耗尽温柔 提交于 2019-12-06 16:08:31
I want list of items to be displayed along with each having a blank textfield to fill amount on my JSP page and once I fill the required items amount, I will submit. I have ExampleAction class as below, where I have populate() method which I fire first so that items are filled. I fire URL : http://localhost:8084/WebExample/populate.action. Same ExampleAction has execute mtd which I call on SUBMIT button action from JSP page. But my problem is in execute method, I am unable to get the objects in list i.e. exList. Is this because an instance of the action class is associated with just one

How to pass object from action class to JSP using Bean in Struts2?

☆樱花仙子☆ 提交于 2019-12-06 08:47:35
I have to send object of Bean class back to JSP from my action class. I am instantiating the Bean class in my action class and and setting some values in my Action class. ElasticitiesVariable elasticitiesVariable = new ElasticitiesVariable(); elasticitiesVariable.setAuto_Auto_cost_peak("-0.047"); elasticitiesVariable.setAuto_Ride_cost_peak("0.000"); elasticitiesVariable.setAuto_Van_cost_peak("0.000"); elasticitiesVariable.setAuto_Transit_cost_peak("0.050"); elasticitiesVariable.setAuto_Bike_cost_peak("0.000"); and in my JSP I am declaring the bean class as well. <s:bean name="org.apache.struts

Struts 2 - Understanding the working between OGNL and params interceptor

醉酒当歌 提交于 2019-12-06 04:43:30
I am new to Struts 2. I am studying it from the book Struts2 In Action. I am having difficulty in understanding some concepts in OGNL which are as follows- We know that params interceptor moves the data from the request parameters to the action object in ValueStack . Now while reading, I came upon a line that says- "The tricky part of the job is mapping the name of the parameter to an actual property on the ValueStack . This is where OGNL comes in. The params interceptor interprets the request parameter name as an OGNL expression to locate the correct destination property on the ValueStack".

How data travels in Struts2?

≡放荡痞女 提交于 2019-12-05 19:20:59
I am trying to understand the path data takes within Struts2, how is data placed on the ValueStack? How can I find out which object is currently present in the ValueStack? What other data can I access from different scopes application, session, request, page? How to decide the scopes my variables should have? Dave Newton That's a lot of questions. The value stack is just a data structure, sort of a combination of a map and stack. Named objects (accessed via the # tag in OGNL) are in the map (like the request scope, say), objects to search through for properties/methods are on the stack. The <s

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

佐手、 提交于 2019-12-04 07:00:46
问题 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

Struts2_ValueStack,OGNL详解

一笑奈何 提交于 2019-12-03 01:54:43
一、ValueStack 1 .ValueStack是一个接口,在struts2中使用OGNL(Object-Graph Navigation Language)表达式实际上是使用 实现了ValueStack接口的类OgnlValueStack.它是ValueStack的默认实现类. 2 .ValueStack贯穿整个action的生命周期,每一个action实例都拥有一个ValueStack对象,其中保存了当前action对象和其他相关对象. 3 .struts2把ValueStack对象保存在名为:struts.valueStack的request域中.即ValueStack作用域为request.当action创建的时候,ValueStack就创建了,action被销毁的时候,ValueStack就销毁了 4 .ValueStack中的数据分两部分存放:root(栈结构,CompoundRoot)和context(map形式,OgnlContext) (1) * 其中的root对象是CompoundRoot,CompoundRoot继承了ArrayList,提供了额外的方法:push(),和pop()方法, 用来对root对象中所包含的数据进行存取.正是由于这两个方法,CompoundRoot变成了一个栈结构. * struts2中,一个请求在最终到达Action的方法之前