ognl

How to retrieve the value while displaying contents in JSP

我是研究僧i 提交于 2019-12-11 07:46:20
问题 I am facing problem in below code <s:form action="updateBankInfo.action" enctype="multipart/form-data" method="post" theme="simple"> <s:actionerror /> <div style="font-family:Times New Roman;font-size:30px; padding-left: 250px;">Bank Info</div> <div> <div class="label"><s:text name="Payee Name* :"/></div> <div class="input"><s:textfield value="%{#session.payeeName}" name="bean.payeeName" readonly="false" /></div> <div><s:fielderror fieldName="bean.payeeName"/></div> </div> <div> <div class=

Struts2 display image / get image url from a properties file

99封情书 提交于 2019-12-11 07:29:25
问题 In a project that I got assigned which is using Struts2 I need to do the following things, but I'm new to using Struts2. Move text from titles and most common / repeating texts to a .properties file. Change URLs from images to make the system parameterized, so they should be in the same .properties file as well. I've been able to change some of the titles, first linking Struts2 with my .properties file, following this answer. Content.properties login.logo=/resources/media/login.png login

How to access OGNL tracing evaluations in Struts 2?

[亡魂溺海] 提交于 2019-12-11 01:23:49
问题 I was told to optimize a web application. To do so I use JProfiler. I noticed a large part of the response time is spent in the presentation layer. Especially, when the code builds the HTML code. Drilling down this bottle neck, I saw that the code deals a lot with OGNL classes/methods (nearly 50% of the calls). I tuned the JSP code (see below for details) by removing some unnecessary OGNL statements. I managed to gain 200ms. However the code still spend more than 2000ms on average in this

Struts 2 - Accessing different properties on the ValueStack sharing the same name

泄露秘密 提交于 2019-12-11 00:35:34
问题 Struts 2 will resolve all property names during view rendering against the top object in the ValueStack first. But how can one access a property with the same name on the object lower on the stack? Example: Let's say I have an Action class called MyAction and it has a a logDate property. In the view rendered after this action is invoked, there's this: <s:iterator value="users" status="itStatus"> <s:property value="logDate"/> </s:iterator> Now imagine a User object also has a logDate property.

comparing two valuestack string values in JSP - struts2

ⅰ亾dé卋堺 提交于 2019-12-10 21:16:07
问题 Thanks in advance for your time. I need to preselect a radio button if it has a saved value. I basically need to compare 2 strings in the valuestack to determine this. (I can't use <s:radio at the moment because of some business rules I need to attach based on other input elements in the form). I tried to do <s:set the value of the saved id inside s:iterate like below and then compare them like below but obviously I didnt get it right. <s:set var="savedId" value="%{flag.problemId}"/> <s

why jsp fires a PropertyNotFound?

青春壹個敷衍的年華 提交于 2019-12-10 15:58:38
问题 Writing in a JSP: ${a.b.c} throws 'c' PropertyNotFound, but writing <s:property value="#a.b.c"/> works fine. I'd appreciate if someone can explain why ${a.b.c} doesn't work? UPDATED: In the same JSP, accessing to another bean f such as ${a.f.d} it finds d correctly. I have checked that property c in ${a.b.c} exists. 回答1: Nice Question.If you have not specified getter setters for property c in b then this error will occur Propertynotfound for ${a.b.c} But <s:property value="#a.b.c"/> will not

ognl对象导航图语言

拥有回忆 提交于 2019-12-10 12:14:18
功能:解决复杂map对象下数据获取处理的问题。 依赖: 用旧版的 话不多说 直接上代码,对于不同类型的值的获取: public class OgnlUtils { /** * @return java.lang.Boolean * @throws * @author zhengwentao * @Description 获取String类型 * @date 2019/11/8 10:31 * @params [ognl, root] */ public static String getString(String ognl, Map<String, Object> root) { try { return Ognl.getValue(ognl, root).toString(); } catch (OgnlException e) { throw new RuntimeException(e); } } /** * @return java.lang.Boolean * @throws * @author zhengwentao * @Description 获取数字类型 * @date 2019/11/8 10:31 * @params [ognl, root] */ public static Number getNumber(String ognl, Map<String,

Struts2 sending list data from JSP to Action class: alternative way

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:37:19
问题 I was explaining to a colleague the way of getting list data from a JSP page to back to the action class by using indices as explained here and here. He didn't quite understand and fumbled a bit on his own until he suddenly he made it work by not using indices at all! In his JSP page he had: <input type="checkbox" name="contactNameList" value="someValue1"> <input type="checkbox" name="contactNameList" value="someValue2"> <input type="checkbox" name="contactNameList" value="someValue3"> <input

Comparing Strings in Struts2 <s:if> Tag

☆樱花仙子☆ 提交于 2019-12-10 11:28:35
问题 I have an index.jsp page wherein certain elements turn on/off depending on whether the user has logged in or not. <head> <s:set var="accessType" value="GUEST" /> <s:if test="#session.containsKey('currentAccessType')"> <s:set var="accessType" value="#session.currentAccessType" /> </s:if> </head> <body> <nav> <s:if test="#accessType.equals('GUEST')"> <ul> <li><a href="index.jsp">Home</a></li> <li><a href="#">Login</a></li> <li><a href="http://www.mywebsite.com" target="_blank">Main Site</a></li

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

▼魔方 西西 提交于 2019-12-10 10:58:46
问题 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