Please help me with the issues regarding the version upgrade of struts2 ((2.3.16.3→2.3.35)!!!

Asked 2 years ago, Updated 2 years ago, 147 views

Nice to meet you, nice to meet you.
I have a question regarding the version upgrade of struts2 (2.3.16.3→2.3.35), but if you are an expert, please help me.
Thank you for your cooperation.

Currently, I have replaced the jar file and the following message appeared on the jboss side when I was running.

JBWEB000236: Servlet.service() for servlet jsp thread exception: tag 'select', field 'list', name 'xxxx.xxxxTiming': The requested list key'#_AAA_list' could not be resolved as a collection/array/map/enumeration/type {Example}:

Affected Source Code (jsp)

<td width="60%">   
<s:set var="_AAA_list" value="%{#{}}"/>     
<s:iterator value="#xxx.xxxList" var="item">    
<s:set var="BBBValue" value="#item.value"/>
<%java.lang.String BBBValue= 
(java.lang.String) pageContext.getAttribute("BBBValue");%>  
<%if(XXXXX.checkXXX(request, "/xxx/xxx/xxx/dummy_"+BBBValue)){%>    
<s:if test="#item.value==\"x\"|#item.value==\"y\"> 
<s:set var="_AAA_list" value="%{#_AAA_list.put(#BBBValue, #item.name),
 #_AAA_list}"/>    
</s: if>     
<%}%>   
</s:iterator> 
<s:select name="xxxx.xxxxTiming" list="#_AAA_list" 
value="#xxx.xxxx.xxxx.xxx"/>           
<s:fielderror fieldName="xxx.xxxx"/> 
</td>

Tried

After a lot of research, when <s:select was displayed, #_AAA_list was found to be the cause of null.
Debugging also shows the item.value, item.name,
The neck is value="%{#_AAA_list.put(#BBBValue, #item.name), #_AAA_list}", which is causing #_AAA_list to be null.

Supplementary information (for example, FW/Tool Version)

In order to upgrade the version, ognl-3.0.6.jar was also uploaded to ognl-3.0.21.jar.

The above code goes well to 2.3.16.3 in struts, but not to 2.3.35.

struts

2022-09-29 21:19

1 Answers

It has been repaired and resolved as below.Thank you for everything.

<s:set var="_AAA_list" value="%{#{}}"/> 

<s:set var="_AAA_list" 
value="#@java.util.LinkedHashMap@{}"/>

Modify to

<s:set var="_AAA_list" value="%{#_AAA_list.put(#BBBValue, #item.name),
 #_AAA_list}"/> 

<s:set value="#_AAA_list.put(#BBBValue, #item.label)"/> 

I modified it to , and it worked.


2022-09-29 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.