ognl

Struts2 - JSP EL - Concatenation doesn't seem to work

◇◆丶佛笑我妖孽 提交于 2019-11-30 22:42:13
Trying to figure out this issue for a long time... I am setting a variable with a value from an Object. <s:set name="bodyText" value='First Name "myObject.name"'/> and trying to print it in the following ways.. None of these works. "${bodyText}" "<s:property value="#bodyText" />" "${#bodyText}" "%{bodyText}" "%{#bodyText}" Not sure the problem is with I tried the following as well: <s:set name="bodyText" value='First Name "${myObject.name}"'/> But it did not work. The value attribute should be an object. OGNL uses quotes to delimit a string object, other quotes should be escaped. And use var

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)

Struts 2 <s:if> tag How to get action name to be evaluated in jsp

时光毁灭记忆、已成空白 提交于 2019-11-30 18:27:27
问题 Now I can get any desired results if I use the <s:if> tag in Struts2 <s:if test="status==1"> //do some stuff </s:if> but I don't know how to get the action currently executed, I am expecting like <s:if test="action==addaction"> //do some stuff </s:if> 回答1: You can get action name from the context <s:if test="#context['struts.actionMapping'].name=='addaction'"> do some stuff </s:if> 回答2: Since Struts version 2.3.34 and 2.5.13 #context is not available anymore because of security reasons (see

struts 2 action with no setter getter

半世苍凉 提交于 2019-11-30 18:10:47
问题 I would like to create an action class with no setter and getter on properties for the data coming from the user interface. Instead, I would like to use ServletActionContext.getRequest().getParameterMap() in my own builder class to construct the object. I had created my Action class with no properties. When I am submitting my form I am running into ognl.OgnlException: target is null for setProperty(null, "field-name", [Ljava.lang.String;@5513fab7) Is there any additional conventions or

Using a LabelValueBean properly

[亡魂溺海] 提交于 2019-11-30 17:50:12
问题 I have a variable: private ArrayList<LabelValueBean> circleNameIdList; inside my Action class where it's value get populated. I want to display the label in my drop-down in JSP and when one label is selected, the corresponding value to that particular label in circleNameIdList to be passed to the server. Eg.: If label: NewYork is selected then it's corresponding id = 5 , is sent to the server. How can I achieve this? Up till now I was doing like this in JSP: <s:select list="#session

String Split using struts2

和自甴很熟 提交于 2019-11-30 16:33:36
I like to split the string in my view.jsp page using struts2. Please help me out to solve this issue. I would like to split the string value using comma in languagesKnown which I get value from Database. for example languagesKnown contains string like "tamil,English,Malayalam" . So I like to split the string using struts2 <div class="personal-row1" style="width:90.4%;"> <i class="icon-align-left icon-grey1"> </i> <span class="blue1"> Languages Known: </span> <!--<span class="price free"><span>Free</span></span>--> <span class="lang-tab"> <s:property value="languagesKnown"/> </span> <span class

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

Struts2 redirecting to another action with unknown amount of parameters

谁说我不能喝 提交于 2019-11-30 10:33:00
I have a login action which after succesful execution redirects to the previous page (I store the previous page in my session so I can fetch it later). In Struts2, I can find two ways to do this redirection: <action name="login" class="com.myapp.login.Login"> <result name="redirect" type="redirect">${previousAction.requestURL}</result> </action> In this example, the getPreviousAction().getRequestURL() method (this is a selfmade method, its not ntive to struts2) will be invoked and this will return the url of the previous page as intended, for example: somenamespace/index.action There is also

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

Map-backed Actionform alternative in Struts 2

余生颓废 提交于 2019-11-30 10:11:46
In Struts 1, I have used map-backed action form to get dynamic fields values. public MyForm extends ActionForm { private final Map values = new HashMap(); public void setValue(String key, Object value) { values.put(key, value); } public Object getValue(String key) { return values.get(key); } } Below is the code I have used. JSP <form action="/SaveAction.do"> <input type="text" name="value(dynamicNames)" value="some value"> </form> Action public class SaveAction extends ActionSupport implements ModelDriven<MyForm> { private MyForm myForm = new MyForm(); @Override public MyForm getModel() {