ognl

OGNL Array and List Indexing

馋奶兔 提交于 2019-12-07 05:35:30
问题 I'm sending this parameter to my struts action cdata[1]=bar In my action I'm interested in the index and the value. I defined a getter/setter pair for CDATA as the OGNL documentation suggests: public void setCdata(int index, String value){ LOG.info("setData; key="+ key +"; value="+ value); // store index and value; } public String getCdata(int index){ return null; // don't really need a setter } This is the Exception I get: 2013-04-29 15:38:49,792 [http-apr-8080-exec-3] WARN com.opensymphony

struts 2, tiles 2 dynamic title

隐身守侯 提交于 2019-12-07 03:10:10
问题 I am using tiles 2.0.6 as my template framework together with struts 2.1.6. I am writing a simple cms page and want to let the user to define the title of each html page. I have a title definition like this <definition name="base" template="/WEB-INF/jsp/templates/base.jsp"> <put-attribute name="title" value=" "/> <put-attribute name="header" value="/WEB-INF/jsp/templates/header.jsp"/> <put-attribute name="content" value="dummy"/> <put-attribute name="footer" value="/WEB-INF/jsp/templates

MethodFailedException in ognl.OgnlRuntime.callAppropriateMethod

若如初见. 提交于 2019-12-07 02:50:43
问题 I have a working Action and JSP form that I'm using for creating new entities in my very basic Struts 2.2.1.1 app. I'm trying to modify the app to re-use the same JSP form for the editing of entities. I added a "hidden" ID tag and now I'm getting errors when I submit the form. Can someone please give me some assistance? I've Googled this issue and seen others posting similar errors but I'm not sure how to resolve it. Excerpt from Stack Trace when I submit the form: 2011-05-02 11:09:36,132

Struts 2 Select Tag Default Value

自作多情 提交于 2019-12-07 01:18:26
I'm creating a database record edit form using Struts. <s:select id="status" name="newRecord.status" list="statusTypes" listKey="id" listValue="description" label="Status:" value="" /><br /> Example list: Status' list: 1 Open 2 Closed 3 Pending I want to set a default value on the status field as the current status which is stored in record.status which contains the string representation e.g. "Open" . If I set value="%{record.status} it doesn't work because that's not any list key. Is there a way I can set this value when I only have the string representation to work with? Or should I redesign

Struts 2 using StringUtils in validator expersions

怎甘沉沦 提交于 2019-12-06 22:50:34
We are using Struts 2 validators @FieldExpressionValidator and @ExpressionValidator . These validators check on OGNL expression. There are lots of cases where we deal with Strings in these expressions. expression="(captcha=='' && captcha== null || ....) We find it is very useful if we can use StringUtils ( isEmpty ,trimToEmpty,... ) here. As we set the struts.ognl.allowStaticMethodAccess to false, for security issues, we tried to solve it by adding this getter to action public StringUtils getStringUtils(){ return new StringUtils(); } and then stringUtils.isEmpty(captcha) in the expression. But

在Mybatis的xml文件调用java类的方法

余生颓废 提交于 2019-12-06 17:48:24
在 mybatis 的映射 xml 文件调用 java 类的方法:使用的是 OGNL 表达式,表达式格式为: ${@prefix@methodName(传递参数名称)} 因为我比较懒,每次都要手动给 createBy 赋值,想有没有一种简单的方法,百度一番,搜到了 mybatis 还可以调用 java 类的方法 调用saveDoc方法的时候,才会去调用SecurityUtils类的getUserId方法 <insert id="saveDoc"> INSERT INTO `doc`( `phone`, `create_by`, `create_time`) VALUES ( '1541234512','${@com.xxx.common.utils.SecurityUtils@getUserId()}', now()); </insert> 注意: 方法必须为 静态 方法 MyBatis常用OGNL表达式 e1 or e2 e1 and e2 e1 == e2,e1 eq e2 e1 != e2,e1 neq e2 e1 lt e2:小于 e1 lte e2:小于等于,其他gt(大于),gte(大于等于) e1 in e2 e1 not in e2 e1 + e2,e1 * e2,e1/e2,e1 - e2,e1%e2 !e,not e:非,求反 e.method(args

Retrieving values from list in execute() method

耗尽温柔 提交于 2019-12-06 16:08:31
I want list of items to be displayed along with each having a blank textfield to fill amount on my JSP page and once I fill the required items amount, I will submit. I have ExampleAction class as below, where I have populate() method which I fire first so that items are filled. I fire URL : http://localhost:8084/WebExample/populate.action. Same ExampleAction has execute mtd which I call on SUBMIT button action from JSP page. But my problem is in execute method, I am unable to get the objects in list i.e. exList. Is this because an instance of the action class is associated with just one

Struts2 OGNL EL JSTL 四大标签的区别 (原帖不明。自留)

烈酒焚心 提交于 2019-12-06 15:15:09
我之前虽然会用,但是一直分不清彼此之间有什么区别,所以查找资料,将它们进行整合区分,加深了解, 一 介绍 1.Struts2的作用 Struts2标签库提供了主题、模板支持,极大地简化了视图页面的编写,而且,struts2的主题、模板都提供了很好的扩展性。实现了更好的代码复用。Struts2允许在页面中使用自定义组件,这完全能满足项目中页面显示复杂,多变的需求。 Struts2的标签库有一个巨大的改进之处,struts2标签库的标签不依赖于任何表现层技术,也就是说strtus2提供了大部分标签,可以在各种表现技术中使用。包括最常用的jsp页面,也可以说Velocity和FreeMarker等模板技术中的使用 2.Struts2分类 (1)UI标签:(User Interface, 用户界面)标签,主要用于生成HTML元素标签,UI标签又可分为表单标签非表单标签 (2)非UI标签,主要用于数据访问,逻辑控制等的标签。非UI标签可分为流程控制标签(包括用于实现分支、循环等流程控制的标签)和数据访问标签(主要包括用户输出ValueStack中的值,完成国际化等功能的) (3)ajax标签 3.Struts2标签使用前的准备: (1)在要使用标签的jsp页面引入标签库: <%@ taglib uri="/struts-tags" prefix="s"%> (2)在web

Struts2 Datetime picker displayformat issue

橙三吉。 提交于 2019-12-06 14:39:09
A issue I am facing with struts2.0.14's date time picker tag The problem is that struts2 datetimepicker displayformat attribute must always be set to format of tomcat server date time format else the submitted values are null. Change Date time setting by in Win 7: RightClick bottom right corner date. Click on Change Date & Time Settings Change calender settings Change Regional Settings Set Format as English(India) Repro Steps Change the Regional Settings as mentioned above & restart the tomcat server. Now do not use any displayformat or use display format other than "dd/mm/yyyy" in date time

Retaining values between multiple JSPs and Actions in Struts 2

瘦欲@ 提交于 2019-12-06 14:29:38
问题 My struts project structure is as follows: page1 -> action1 -> page2 -> action2 -> page3 What i need is for a value i entered in an input tag in page1 to be accessed in action2. Here is my code: page1: <div class = "container"> <s:form id = "idinput" method = "post" action = "idEntered"> Enter id: <input id = "txtid" name = "txtid" type = "text" /> <input id = "cmdsubmit" name = "cmdsubmit" type = "submit" value = "enter details" /> </s:form> </div> action1: public class AddId extends