ognl

Accessing static variable using OGNL in Struts2

筅森魡賤 提交于 2019-12-10 03:50:59
问题 Good day! I am reading Manning's struts2 book and one of the topic is accessing the static variable using OGNL using the syntax @[fullClassName]@[property or methodCall] so I tried it on my program and my code is as follows: BEAN: public class ContactsBean { private static int count = 1; //getter and setter } ACTION: private ContactsBean contacts; //getters and setters JSP: <s:property value="@com.demo.bean.ContactsBean@count" /> or <s:property value="@vs@count" /> //valuestack method but it

how can i use request parameter in struts2 if tag

一笑奈何 提交于 2019-12-09 21:46:53
问题 i have a link like this : http://localhost:8080/ESA/login.jsp?login=failed in end of above link a set a parameter with name login and value failed . how i can use this parameter in jsp page with struts if tag. I use following code but it don't work. <s:if test="%{#parameters.login='failed'}"> <div class="error"> <s:text name="user.login.failed"></s:text> </div> </s:if> 回答1: Try with <s:if test="%{#parameters.login[0]=='failed'}"> The two problems were in your code: The = sign is an assignment

How does Struts2 ValueStack take care of multiple requests

自古美人都是妖i 提交于 2019-12-09 01:47:36
问题 I understand ValueStack was introduced in Struts2 and one more change from Struts1 model is now a new ActionObject is instantiated for each request. So we can define instance variables without worrying about multi threading issues. The way interceptors and JSPs access the instance variables from the ActionObjects is through the ValueStack . But the way ValueStack is implemented (or at least used by Struts2 framework) is by ValueStack . to make the access easier so that we don't need to

Comparing dates using struts 2 in JSP

孤街浪徒 提交于 2019-12-09 01:38:10
问题 I want to compare two dates using Struts2 One is returned from the backend (test.currentDate) == "2012-11-15)" The other one I just set "2014-10-19" How can I compare the two dates? My code is as follows: <s:set name="currentDate" value="%{test.currentDate}"/> <s:set name="futureDate" value="2014-10-19"/> <s:if test="%{#currentDate.before(#futureDate)}"> <s:text name="test"/> <s:date name="test.currentDate" format="MM/yy"/> </s:if> <s:else> <s:text name="test2"/> </s:else> 回答1: In the above

How can I get the revision number into an Ant property in Luntbuild?

心不动则不痛 提交于 2019-12-08 20:44:35
I'm sure this must be possible: I want to have the revision number (from Subversion) put into a property that is accessible from Ant when my build runs in Luntbuild. There must be an OGNL expression that I can add to the Build Properties box on the configuration page for my Ant builder. Does anyone know what it is? You might find using either the SvnAnt or svntask Ant tasks to get the Subversion revision number directly in your Ant script might be a valid alternative. 来源: https://stackoverflow.com/questions/1065130/how-can-i-get-the-revision-number-into-an-ant-property-in-luntbuild

How to call an action method using OGNL

心已入冬 提交于 2019-12-08 20:04:39
How to call an action method using OGNL? helloAction.java public String getQuote() { return "Don't think, just do"; } success.jsp <b>quote() :</b> <s:property value="quote()"/> <br> struts.xml <action name="greet" class="com.struts2.helloAction" > <interceptor-ref name="firewallStack"></interceptor-ref> <result name="SUCCESS">/WEB-INF/resources/success.jsp</result> <result name="input">/WEB-INF/resources/success.jsp</result> </action> I got the ref link from struts 2 OGNL This quote() method is not called. I am using xwork-2.0.1.jar and ognl-2.6.11.jar. This quote() method is not called. I am

Need to check userid existence with struts 2

半世苍凉 提交于 2019-12-08 18:20:28
I am using struts 2 framework and trying to see as what is the best way to check for user id existence in the database. In my last project, I did this with jquery ajax,but was not satisfied with it. In this project, I am using validation framework for server side checks for input fields and jquery validate plugin on client side. I have a DAO class which makes call to DB to do checks for existence,I dont want to use jquery ajax but would prefer to go with struts 2 validation framework. Is their a way I can use my output of this DAO class and combine it with my validation xml either using field

Java - Display list<Object[]> in a jsp with struts2

扶醉桌前 提交于 2019-12-08 12:41:39
问题 I have an issue with Struts2. I created a List<Object[]> myList and filled it with a query result. My query get fields from two tables so I can't put the result on a bean instance (I guess). I would like to display myList on a JSP with Struts2 trough an iterator but I can't get the values of the list. On the DAO (I use Hibernate): List<Object[]> myList = session.createQuery("select a.name, b.description, c.description from test a, test2 b where a.id = b.id "); On the JSP, If I use this code:

Iterating through 2D ArrayList and displaying it on JSP page

牧云@^-^@ 提交于 2019-12-08 08:19:50
问题 I tried looking this up but didn't find anything that answered my question. So what I've got is something that looks like this: private List<List<String>> data = new ArrayList<List<String>>(); This has a getter / setter and is being populated by this line: String[] name = new String[columnCount]; for (int i = 0; i < columnCount; i++ ) { name[i] = rsmd.getColumnName(i+1); Array tempArray = rs.getArray(name[i]); data.add((List<String>) tempArray); } In my jsp I know I need something like this:

How can I get the revision number into an Ant property in Luntbuild?

笑着哭i 提交于 2019-12-08 08:16:50
问题 I'm sure this must be possible: I want to have the revision number (from Subversion) put into a property that is accessible from Ant when my build runs in Luntbuild. There must be an OGNL expression that I can add to the Build Properties box on the configuration page for my Ant builder. Does anyone know what it is? 回答1: You might find using either the SvnAnt or svntask Ant tasks to get the Subversion revision number directly in your Ant script might be a valid alternative. 来源: https:/