ognl

Struts2 tags seem to evaluate inconsistently

让人想犯罪 __ 提交于 2019-12-02 06:30:30
问题 I have an issue with some Struts2 tags mixed with OGNL. To overcome the fact that you cannot nest evaluation of expressions in OGNL, e.g., %{foo[%{bar}]} , I use successive assignment to variables to get the results that I need. In the following code, the var grpIndex evaluates correctly, e.g., '6' or '7' in my case, and prints out correctly on the next line. The following statement (line 3) also evaluates correctly, e.g., 'stage' or 'prod' in my case. However, in the fourth line I try

How to pass a Map<ObjectA, List<ObjectB>> to action in Struts 2

一笑奈何 提交于 2019-12-02 05:24:43
问题 I have a event object, inside there is a Map<ObjectA, List<ObjectB>> , the ObjectA is the label, and the list<ObjectB> are table rows. With following code, I can display the tables correctly, but when I submit the form to Action class, the map is null inside the event. JSP CODE: <s:iterator value="event.planMap" var="map" > <h4>Plan Type: <s:property value='key' /></h4> <table id="plan"> <s:iterator value="value" status="stat" var="detail" > <tr> <td><input type="text" id="name" name="event

How to get data from JSP to Action class by id instead of property in Struts 2?

余生长醉 提交于 2019-12-02 03:56:36
I am doing on Java Struts 2 framework. Normally, I can get data from my JSP through the get set method in Form.java (action class). Below is my example : In main.jsp file: <html:text property="campaignName" size="50" maxlength="50" /> thus, I can get this text box name by get set method in the action class, the below is code from mainForm.java : private String campaignName = null; public String getCampaignName() { return campaignName; } public void setCampaignName(String campaignName) { this.campaignName = campaignName; } However, because of I want to use jQuery to do something, I no longer

Using <s:iterator> to populate a dynamic arraylist over multiple columns

社会主义新天地 提交于 2019-12-02 02:59:04
I am trying to populate an ArrayList over multiple table columns, this was originally done using Scriptlets on our old page but I know that the practice is frowned upon now. And I am having trouble translating it over using struts tags. I want the table to end up like this, Checkbox 1 Name 1 Checkbox 2 Name 2 Checkbox 3 Name 3 Checkbox 4 Name 4 etc.... This is the original scriptlet code: <% for (int j=0; j < getDocumentList().length; j++) { setPacket(j); setStringIndex(Integer.toString(j)); %> <tr> <td><input type="checkbox" name="displayTag<%= getStringIndex() %>"/></td> <td class="labelText

“Select” not populated from List<String> in struts

不想你离开。 提交于 2019-12-01 21:26:22
I have the following sources: struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="true" /> <constant name="struts.custom.i18n.resources" value="ApplicationResources" /> <package name="vislabWebShop" extends="struts-default"> <action name="UserForward"> <result>/pages/Login.jsp</result> </action> <action name="UserLogin" class="vislabWebShop

Struts2 - Setting a property from a static list String property using OGNL not working

那年仲夏 提交于 2019-12-01 21:03:50
I'm trying to set a hidden input value using the struts2 framework. The input value is an unchanging value, so I'd like to set it via a static reference rather than worrying about setting it possibly in multiple places in the Controller. Here is the list definition: package com.packagename.models; public class UsernameModel implements Serializable, Comparable<UsernameModel> { ... /** * <P>A static container of the predefined username types. */ public static final class UsernameTypes { public static final String ALIAS = "Alias"; public static final String ASSIGN_NUM = "Assignment Number"; } ...

Struts2中的OGNL详解

一世执手 提交于 2019-12-01 17:14:22
首先了解下 OGNL的概念 : OGNL是 Object-Graph Navigation Language的缩写,全称为 对象图导航语言,是一种功能强大的表达式语言,它通过简单一致的语法,可以任意存取对象的属性或者调用对象的方法,能够遍历整个对象的结构图,实现对象属性类型的转换等功能。 此外,还得先需弄懂OGNL的一些知识: 1.OGNL表达式的计算是围绕OGNL上下文进行的。 OGNL上下文实际上就是一个Map对象,由ognl.OgnlContext类表示。它里面可以存放很多个JavaBean对象。它有一个上下文根对象。 上下文中的根对象可以直接使用名来访问或直接使用它的属性名访问它的属性值。否则要加前缀“#key”。 2.Struts2的标签库都是使用OGNL表达式来访问ActionContext中的对象数据的。如:<s:propertyvalue="xxx"/>。 3.Struts2将ActionContext设置为OGNL上下文,并将值栈作为OGNL的根对象放置到ActionContext中。 4.值栈(ValueStack) : 可以在值栈中放入、删除、查询对象。访问值栈中的对象不用“#”。 Struts2总是把当前Action实例放置在栈顶。所以在OGNL中引用Action中的属性也可以省略“#”。 5.调用ActionContext的put(key,value

Struts2最新OGNL漏洞

試著忘記壹切 提交于 2019-12-01 12:48:22
There are many Struts 2 developers familiar with the Struts 2 development mode on which more verbose logs are produced and handy resource reloading is done on a request basis to avoid restarting the server every time we change a property, validator and so on. What it is not so well known (actually it doesn’t even appear in the Struts 2 devmode site ) is that it enables a OGNL injection backdoor allowing the developers to check their Value Stacks with ease and from a handy OGNL console or request parameter. This handy feature for developers turns into a security nightmare if application is

Struts2 s:if test for non-null value

六月ゝ 毕业季﹏ 提交于 2019-12-01 12:39:12
问题 I am wanting to test for a non-null value using a struts2 tag. This works if I use the following: <s:if test="myObject.myField != null">..stuff..</s:if> It also seems to work if I miss out the not-null part, and just do: <s:if test="myObject.myField">..stuff..</s:if> However, when myField is a String , this no longer works. I prefer the second form as it is more concise, and seems less like putting code in my presentation layer. But I don't want to use it if it's an undocumented feature which

How to add two submit buttons on one form in Struts 2

*爱你&永不变心* 提交于 2019-12-01 12:14:11
I'm developing an application using Struts2. My application is for online shopping. My task is updating and removing the shopping cart item. I have a JSP page and it has 4 text fields. I need to submit these text field's data to the Modify action. Updating and removing submit buttons are in same page, same form. How do I determine which is the button I've clicked on JSP form? My form is: <s:form action="ModifyCart"> <s:textfield readonly="true" name="shoppingCart.item.id" label="Item Code" value="% item.id}"/> <s:textfield readonly="true" label="Item Name" value="%{item.itemName}"/> <s