ognl

Struts 2 using StringUtils in validator expersions

不想你离开。 提交于 2019-12-08 08:07:37
问题 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

Need to check userid existence with struts 2

∥☆過路亽.° 提交于 2019-12-08 08:03:46
问题 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

Understanding OGNL expressions in Struts2

大憨熊 提交于 2019-12-08 07:24:50
问题 The following code displays links using <s:a> of Struts starting from 1 to 10. <s:set var="currentPage" value="2"/> <s:set var="begin" value="1"/> <s:set var="end" value="10"/> <s:iterator begin="%{begin}" end="%{end}" step="1" var="row" status="loop"> <s:if test="%{#currentPage eq #row}"> <!--???--> <span><s:property value="%{#row}"/></span> </s:if> <s:else> <s:url id="pageURL" action="someAction" escapeAmp="false"> <s:param name="currentPage" value="%{row}"/> </s:url> <s:a href="%{pageURL}"

Struts2 Datetime picker displayformat issue

这一生的挚爱 提交于 2019-12-08 06:26:22
问题 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

Change action attribute of Form for different action methods in Struts2

穿精又带淫゛_ 提交于 2019-12-08 03:20:36
问题 I have created a from in JSP page name add.jsp to save data like this <s:form action="AddDomain"> <s:push value="idp"> <s:textfield name="domainName" label="Domain Name" /> <s:textfield name="url" label="Domain URL" /> <s:textfield name="noOfLicense" label="License Purchased" /> <s:textfield name="licenseExpireDate" label="License Expire Date" title="YYYY-MM-DD like 2013-01-21" /> <s:textfield name="userActiveDuration" label="Active User Duration" title="please mention in days" /> <s:textarea

Is it possible to set a struts token with a GUID as a token name?

本秂侑毒 提交于 2019-12-08 02:25:31
问题 I'm trying to set a struts token in a form with a unique name for each form. Is there way to set up the token in a way like <s:token name="<some random generated characters>" . I was planning to use the TokenHelper.generateGUID() to generate the token name, if possible. I've tried setting a variable using <s:set var="tokenName" value="<%=TokenHelper.generateUID()%>"/> , then setting the token using <s:token name="${tokenName}"/> . I'm getting tld error about setting the in the tag. Here is

How data travels in Struts2?

跟風遠走 提交于 2019-12-07 18:23:38
问题 I am trying to understand the path data takes within Struts2, how is data placed on the ValueStack? How can I find out which object is currently present in the ValueStack? What other data can I access from different scopes application, session, request, page? How to decide the scopes my variables should have? 回答1: That's a lot of questions. The value stack is just a data structure, sort of a combination of a map and stack. Named objects (accessed via the # tag in OGNL) are in the map (like

Accessing action instance variables and model-driven bean variable values in JSP

北城以北 提交于 2019-12-07 12:05:09
问题 I have searchKey as a variable in action class and model-driven bean object. public class PaymentGateWayAction extends ActionSupport implements ModelDriven<PaymentResponseDTO> { private String searchKey; private PaymentResponseDTO paymentResponseDTO = new PaymentResponseDTO(); // ... } searchKey is also a variable in PaymentResponseDTO . I need to access searchKey from the action class and modeldriven bean based on some conditions. Having varible with same name is bad. But The above one is

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

半世苍凉 提交于 2019-12-07 09:47:56
在 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

Struts2中在Action里面向前端页面传值的方法总结

左心房为你撑大大i 提交于 2019-12-07 07:56:19
来自: http://www.cnblogs.com/hgfrzh/p/3401658.html 由于在Action中并不能直接诶访问Servlet API,但它提供了相关类ActionContext来访问HttpServletRequest、HttpSession和ServletContext,所以在向前端页面传值的方法就出现了多样化。一般我们经常使用的就是通过request、session来传值,至于Application范围这一级别的基本上用的少。 1. 首先如果变量是Action的全局变量,并且定义了Setter方法,那么此时无须做任何更多工作,只要它有值在前端页面就可以取到。此时取值的方法大概有这几种: 使用Java代码:<%= request.getParameter(“str”)%>, <%=request.getAttribute(“str”)%> 这两种方式通常不推荐,原则上html代码不用掺杂Java代码; 使用EL表达式:${str}; 使用Struts2标签:<s:property value=”str” /> ; 使用OGNL表达式:<s:property value=”#request.str”/>. 2. 对应方法体内的局部变量,我们可以放在request里面,也可以放在session里面。但是,只有在必要的时候才放在session里面。 (1