ognl

Creating dynamic URL with 2 action parameters in Struts 2 using OGNL [duplicate]

只愿长相守 提交于 2019-11-28 00:35:24
This question already has an answer here: Passing parameters in URL without query string in Struts 2 2 answers If I have a url: www.myurl.com/books and want to be able to create new <s:url> filtering on author and year: www.myurl.com/books/Sartre/1942 by passing Sartre and 1942 as parameters to the action class which will render the books page with the appropriate results. How to do this in Struts2? I have the backend logic in place so it would be great if: I could reuse the same jsp and action class that the permalink www.myurl.com/books uses. Show the dynamically rendered URL www.myurl.com

Repopulate ArrayList from JSP with Struts 2

你。 提交于 2019-11-27 16:24:30
This is the form I am using to repopulate the ArrayList <form method = "POST" action = "addItemsToTemplate"> <s:iterator value = "myQuestions" var = "quizItem" status="key"> <s:textfield name = "quizItem.question"/> </s:iterator> <input type = "submit" value = "submit"/> </form> This is the action class public class QuizTest extends ActionSupport{ public String execute(){ List<Question> q= myQuestions; System.out.println(myQuestions); return "success"; } public String populateQuestions(){ //more code here } public void setMyQuestions(List<Question> myQuestions) { this.myQuestions = myQuestions

Struts 2 nesting iterators

家住魔仙堡 提交于 2019-11-27 15:35:44
I can't believe how something this simple can seem so hard to do in Struts 2. This is approximately what I would like to do as it would be done in Java. for (Parent parent : parents){ for (Child child: parent.getChildren()){ System.out.println(child.getName()); } } That should translate to something close to this in Stuts tags: <s:iterator var="parent" value="parents"> <s:iterator var="child" value="parent.children"> <s:property value="child.name"/> <s:iterator> <s:iterator> I assume parent.children should be something like ${%(#parent.children)} but I have not found a right combination of ${%

How to insert a value into Set collection in Struts 2

那年仲夏 提交于 2019-11-27 14:33:24
I am doing a project using Struts2 and I have a problem assigning a set collection. Here's my Action (I eliminated the irrelevant part) public class TeamAction extends BaseAction implements ModelDriven<Team> { Team team=new Team(); } Here's my model Team (I eliminated the irrelevant part) private TeamId id; private Set students = new HashSet(0); Here's my JSP part <input type="text" name=team.student[0].id /> Now the problem is I can't insert the right value into this Set collection in by ModelDriven , it will throw a exception. Could you please tell me what to write in JSP file, so I can

org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object

僤鯓⒐⒋嵵緔 提交于 2019-11-27 08:56:26
1 问题描述 mybatis3.2.x版本,做压力测试,并发200用户,出现了如下异常. org.apache.ibatis.builder.BuilderException: Error evaluating expression 'size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object [one, two] [java.lang.IllegalAccessException: Class org.apache.ibatis.ognl.OgnlRuntime can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public"] at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:47) at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:29) at

How to change session scope properties using ognl?

青春壹個敷衍的年華 提交于 2019-11-27 08:33:50
问题 Is it possible to change session scope properties using ognl ? For example, if I have on my session an attribute called PROCESS_CONFIG which is an object with an attribute name , how can one change this attribute name on a JSP? I've tried the following but it doesn't work: <s:textfield value="%{#session.PROCESS_CONFIG.name}" id="PROCESSNAME" name="#session.PROCESS_CONFIG.name"/> When I submit the form and access the session object in my action, through ServletActionContext.getRequest()

I can get property from a session attribute, but not from a session map

柔情痞子 提交于 2019-11-27 07:27:30
问题 I am using SSH2. When I try to got an attribute with <%=session.getAttribute("username") %> , it was just right. But when I tried to get the same attribute with <s:property value="#session.username" /> , I got nothing. Why? Aren't they the same? And when I used the <s:debug> , I got these: Servlet.service() for servlet jsp threw exception org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize

Error setting expression 'spa.amount' with value '[Ljava.lang.String;@10dd65e' )

好久不见. 提交于 2019-11-27 07:18:41
问题 I am trying following code to get data in spa object fields. Thus, I am using the following code but it is showing null values and giving the following error Error setting expression 'spa.amount' with value '[Ljava.lang.String;@10dd65e' ognl.OgnlException: target is null for setProperty(null, "amount", [Ljava.lang.String;@10dd65e) Jsp code: <s:form action="UpdatedPaid" method="post"> <s:if test="paidList.size > 0"> <s:iterator value="paidList" var="pdlst"> <div class="box"> <span class="label

Make ${} operator XSS safe in Struts 2 (same as tapestry)

 ̄綄美尐妖づ 提交于 2019-11-27 05:38:46
As mentioned in http://www.disasterarea.co.uk/blog/xss-vulnerabilities-in-web-frameworks-2/ The ${} is not xss safe in struts 2 while it is safe in tapestry 5. I am not a Tapestry guy, but I want to know if above is correct. As far as I know the ${} is part of JSLT and it does not depend on any web frameworks. So if above sentence is correct and the ${} is XSS safe in tapestry, how can we make it safe in struts 2. Updated: To test it I run struts2-showcase app, opened modelDriven\modelDrivenResult.jsp and add below line: Am I safe ${name} Now when you run the show case and enter <script> alert

Struts 2 dynamic variables

限于喜欢 提交于 2019-11-27 05:25:46
I'm trying to create a dynamic variable in Struts2 using set tag <s:set var="myNum" value="numConst" /> <s:set var="number" value="%{getText('@xxx.CommonConstant@'+#myNum)}" /> numConst will return a dynamic value that retrieved from database. For example, if the value is NINE then number should be @xxx.CommonConstant@NINE I have set the value in my java class so that @xxx.CommonConstant@NINE will return 9 . So far, the value can be displayed with no problem in text tag if I use <s:text name="%{getText(#number)}" /> It will return 9 but it displayed incorrectly when I tried using property tag