ognl

How to iterate Set elements using Struts 2 tags

强颜欢笑 提交于 2019-12-01 08:56:56
I have two Set s set1 contains("A","B","C","D") elements set2 contains("E","F","D","G") elements I want to compare every element of set1 with every element of set2 and display matched elements using Struts2 tags. Try the code below: <s:iterator var="val1" value="set1"> <s:iterator var="val2" value="set2"> <s:if test="#val1 == #val2"> <s:property /><br> </s:if> </s:iterator> </s:iterator> Rearranged to better list the several ways: With two Iterator s: <s:iterator value="setOne" var="first" status="ctr1"> <s:iterator value="setTwo" var="second" status="ctr2"> <s:if test="%{#first == #second}">

OGNL Syntax Issue

主宰稳场 提交于 2019-12-01 08:22:49
问题 I have a Struts 2 JSP page with the following snippet: <s:property value="%{myVariable}" /> which correctly prints out the value of myVariable . Now, I want to pass myVariable to a method in my action that computes a result based on the value of myVariable . I tried the following: <s:property value="%{myMethod(myVariable)}" /> The first line in myMethod prints out a debug statement. With the above snippet, this debug statement was not printed. I then tried this: <s:property value="%{myMethod(

According to TLD or attribute directive in tag file, attribute name does not accept any expressions

倖福魔咒の 提交于 2019-12-01 08:05:12
I write the following code in JSP. <% String p_loginPassword = OpeCommon.LOGIN_PASSWORD; String p_encryptCode = OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE); %> <s:url id="printURL" action="actMod" method="printout"> <s:param name="<%=OpeCommon.LOGIN_PASSWORD %>"><%=OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE)%></s:param> </s:url> It displays error : According to TLD or attribute directive in tag file, attribute name does not accept any expressions How should I write for that, pls give me some suggestions. Don't use scriptlets

Upgrading to struts 2.3.15.1 does not set HashMap values on action class

混江龙づ霸主 提交于 2019-12-01 07:24:28
问题 I upgraded from 2.1.6 to 2.3.15.1 because of the security fixes available in the latest version. However, now the form field values are not posted to the Action class. Basically, I populate the HashMap props from the JSP into the Action class, when the form is submitted. When I upgraded the struts version to 2.3.15.1 this does not work. There has been no code change. When I debugged the code, I noticed that the setProps method is not invoked. Is this not allowed anymore. Is there any

According to TLD or attribute directive in tag file, attribute name does not accept any expressions

[亡魂溺海] 提交于 2019-12-01 07:03:26
问题 I write the following code in JSP. <% String p_loginPassword = OpeCommon.LOGIN_PASSWORD; String p_encryptCode = OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE); %> <s:url id="printURL" action="actMod" method="printout"> <s:param name="<%=OpeCommon.LOGIN_PASSWORD %>"><%=OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE)%></s:param> </s:url> It displays error : According to TLD or attribute directive in tag file, attribute name does not

How to iterate Set elements using Struts 2 tags

夙愿已清 提交于 2019-12-01 05:48:57
问题 I have two Set s set1 contains("A","B","C","D") elements set2 contains("E","F","D","G") elements I want to compare every element of set1 with every element of set2 and display matched elements using Struts2 tags. 回答1: Try the code below: <s:iterator var="val1" value="set1"> <s:iterator var="val2" value="set2"> <s:if test="#val1 == #val2"> <s:property /><br> </s:if> </s:iterator> </s:iterator> 回答2: Rearranged to better list the several ways: With two Iterators: <s:iterator value="setOne" var=

struts2 no longer accepts http map parameters?

╄→尐↘猪︶ㄣ 提交于 2019-12-01 05:45:25
In struts2, I took advantage of built-in OGNL in struts2, naming my inputs like <input name='bag["item"].property'> Which went to getters/setters getBag().get("item").setProperty(value) I've upgraded to struts 2.2.1, and suddently those no longer work: the getter never gets called. The internet is utterly silent on using OGNL in parameters , as if nobody ever made complex forms. How do I get my map-parameters back? It turns out that they hardened restrictions on parameter names to boost security. So I had to add to my struts.xml: <interceptor-stack name="defaultStack"> <interceptor-ref name=

Struts 2 s:select tag dynamic id

风流意气都作罢 提交于 2019-12-01 03:52:40
问题 I have multiple fields of various types in a JSP page and one button. These fields are generated based on the info got from a metadata table that I have created. Since I don't know how many and what type of fields are present, I am giving dynamic id 's to them . I am using Struts 2 tags in my JSP. The issue is with the <s:select> tag: when I give scriplet within the id attribute, it displays the following error : org.apache.jasper.JasperException: /success.jsp(83,12) quote symbol expected <s

struts 2 action with no setter getter

99封情书 提交于 2019-12-01 00:07:26
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 configurations required to convey Struts2 framework to not set properties and stop avoid the exception I am

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

二次信任 提交于 2019-11-30 23:55:16
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> You can get action name from the context <s:if test="#context['struts.actionMapping'].name=='addaction'"> do some stuff </s:if> Since Struts version 2.3.34 and 2.5.13 #context is not available anymore because of security reasons (see WW-4852 ) As a workaround you can use #request which is documented here <s:if test="#request['struts.actionMapping