ognl

Struts 2 - Understanding the working between OGNL and params interceptor

我们两清 提交于 2019-12-22 19:24:37
问题 I am new to Struts 2. I am studying it from the book Struts2 In Action. I am having difficulty in understanding some concepts in OGNL which are as follows- We know that params interceptor moves the data from the request parameters to the action object in ValueStack . Now while reading, I came upon a line that says- "The tricky part of the job is mapping the name of the parameter to an actual property on the ValueStack . This is where OGNL comes in. The params interceptor interprets the

Struts 2 Dynamic message with OGNL

我的梦境 提交于 2019-12-22 14:12:14
问题 In a Struts 2 project, consider below key in message resources: export.filename.accountsummary=customer ${export} The action has export filed with setter and getter. If you call the getText("export.filename.accountsummary") struts will automatically call the getExport() and fill it with correct value. (I think that struts use OGNL too lookup the resource messages that are endorse with ${} ) Is this correct ?! I try to use customer ${#sessionScope.CurrentUser.userName} an expected that struts

How to set the id value for Student in delete()? [closed]

让人想犯罪 __ 提交于 2019-12-20 03:48:29
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I want to initialize Student 's id in delete action StudentAction.java: public class StudentAction extends ActionSupport implements ModelDriven { private List studentList; Student student; StudentDAO sdo = new StudentDAO(); public String delete() { System.out.println("delete action"); System.out

Struts2 - Setting a property from a static list String property using OGNL not working

青春壹個敷衍的年華 提交于 2019-12-20 02:39:23
问题 I'm trying to set a hidden input value using the struts2 framework. The input value is an unchanging value, so I'd like to set it via a static reference rather than worrying about setting it possibly in multiple places in the Controller. Here is the list definition: package com.packagename.models; public class UsernameModel implements Serializable, Comparable<UsernameModel> { ... /** * <P>A static container of the predefined username types. */ public static final class UsernameTypes { public

Checking request parameter value in Struts2 tag

北城余情 提交于 2019-12-19 10:03:36
问题 I have the following code in my jsp: <s:property value="#parameters['test']"/> <br/><s:property value="'1'.equals(#parameters['test'])"/> now if I access this action like this: test.action?test=1 I get the following: 1 false Wondering, why 1 is not equal to 1? 回答1: Edit : There is a difference between "" (double quotes) and '' (single quotes) in OGNL. Double quotes evaluate single characters to strings while single quotes evaluate single characters to Character types. You may put multiple

struts2 no longer accepts http map parameters?

痞子三分冷 提交于 2019-12-19 07:53:21
问题 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? 回答1: It turns out that they hardened restrictions on parameter names to boost

String Split using struts2

╄→尐↘猪︶ㄣ 提交于 2019-12-18 18:20:22
问题 I like to split the string in my view.jsp page using struts2. Please help me out to solve this issue. I would like to split the string value using comma in languagesKnown which I get value from Database. for example languagesKnown contains string like "tamil,English,Malayalam" . So I like to split the string using struts2 <div class="personal-row1" style="width:90.4%;"> <i class="icon-align-left icon-grey1"> </i> <span class="blue1"> Languages Known: </span> <!--<span class="price free"><span

Map-backed Actionform alternative in Struts 2

别来无恙 提交于 2019-12-18 13:37:46
问题 In Struts 1, I have used map-backed action form to get dynamic fields values. public MyForm extends ActionForm { private final Map values = new HashMap(); public void setValue(String key, Object value) { values.put(key, value); } public Object getValue(String key) { return values.get(key); } } Below is the code I have used. JSP <form action="/SaveAction.do"> <input type="text" name="value(dynamicNames)" value="some value"> </form> Action public class SaveAction extends ActionSupport

After having updated struts2 from 2.3.16 to 2.3.32(fix the S2-045), the JSP file can not resolve some Objects' fields

半城伤御伤魂 提交于 2019-12-18 07:21:48
问题 Recently we fixed the struts2's 'S2-045' problem.I updated all the struts2 related jar files including freemarker , ognl , xWork ,etc. I use tomcat8 to deploy my dynamic web project. There were not any Exceptions while starting the tomcat-server. But some problems seemed occur: some values(got from db) should be displayed on the jsp pages dose not show up any more . There is no Exceptions thrown. I also can watch that I have already got the very Objects correctly in the Action Classes . the

Submitting form's data to a java Set

ε祈祈猫儿з 提交于 2019-12-18 07:09:29
问题 Is it possible to submit a form's data to a java Set in an action of Struts2? Action code: class TestAction extends ActionSupport{ private Set<Integer> mySet = new LinkedHashSet<Integer>(); public TestAction(){ } public String test(){ someMethod(mySet); } ... Getters/Setters ... } Form code: <form action="test.action" > <input name="mySet[0]" /> <input name="mySet[1]" /> <input name="mySet[2]" /> <submit /> </form> 回答1: The Set is just a collection, and Struts2 has support for any type of