ognl

What is wrong with headerKey=“-1”?

和自甴很熟 提交于 2019-11-29 08:50:21
What is wrong with: <s:select list="fruits" name="fruitSelect" id="fruitSelect" listKey="fid" listValue="fname" headerKey="-1" headerValue="Pick a fruit!" /> Plenty of online examples use this value: http://www.coderanch.com/t/439139/Struts/wrong-select http://www.mkyong.com/struts2/struts-2-sselect-drop-down-box-example/ BUT the actual documentation (you can view this on the tooltip in Eclipse by hovering over the symbol) says Key for first item in list. Must not be empty! '-1' and '' is correct, '' is bad. -1 seems pretty logical to me and it shouldn't be a valid option anyway. " is correct,

Struts 2 - The usage of %{ } notation

泄露秘密 提交于 2019-11-29 08:03:42
What is the exact use of %{} notation in Struts 2? Can someone explain with a simple example where the code works when %{} is used and does not works when its not used? Used in OGNL to force evaluate the content in brackets as OGNL expression. For example <s:iterator value = "myAnswers" status="stat"> <s:textfield name = "myAnswers[%{#stat.index}].name"/> evaluation of the stat.index should be forced. 来源: https://stackoverflow.com/questions/18491659/struts-2-the-usage-of-notation

Struts2中OGNL,valueStack,stackContext的学习

馋奶兔 提交于 2019-11-29 06:14:36
[/color]学习Struts2,一直不明白表单中的值是怎么传给Action的,上网查了些资料,基本了解了!下面基本是从几个人的BOLG转载过来,以后记不清了再来看~ [color=red]先看看我做的实验 jsp页面 Java代码 <s:form action= "hello/converter.action" method= "post" > <s:textfield name= "point" label= "点" ></s:textfield> <s:textfield name= "point2" label= "2" ></s:textfield> <s:textfield name= "point3" label= "3" ></s:textfield> <s:textfield name= "age" label= "年龄" ></s:textfield> <s:textfield name= "date" label= "日期" ></s:textfield> <s:submit name= "提交" ></s:submit> </s:form> 结果图(是通过<s:debug></s:debug>得到的) value stack: Stack context: 通过图中我们可以看到 valuestack中包括我传递的值(point,point2,point3

Struts2 handle multiple actions in single form

老子叫甜甜 提交于 2019-11-29 04:55:04
I have a form contains three buttons print / export / save . <s:form action="/userAction"> <s:submit type="image" value="%{'print'}" src="/print.png" /> <s:submit type="image" value="%{'export'}" src="/export.png" /> <s:submit type="image" value="%{'save'}" src="/save.png" /> </s:form> How can I map this in struts.xml ? In the struts.xml the action is mapped via the <action tag <action name="userAction" class="... the submit buttons should include method attribute to call corresponding methods of the action <s:submit type="image" value="%{'print'}" src="/print.png" method="print" /> <s:submit

Struts2 accessing enum from JSP

余生长醉 提交于 2019-11-29 02:53:54
问题 I have the following class package com.test; public class SomeClass { public enum COLOR {RED,BLUE} } I want to access values of COLOR enum in my JSP. I've tried the following code but it doesn't work. <s:property value="@com.test.SomeClass.COLOR@RED"/> <s:property value="@com.test.SomeClass@COLOR.RED"/> Any body came across this issue before? [I've already enabled static method access in struts.xml] 回答1: For enum -s there is not need to enable static method access . Enum-s can be accessed

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

♀尐吖头ヾ 提交于 2019-11-28 13:06:51
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(AbstractLazyInitializer.java:167) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation

Calling static method helper class in Struts2 JSP with Action data model value

流过昼夜 提交于 2019-11-28 08:23:41
问题 I'm a Struts2 newbie. I'm using Struts2 with the typical datamodel UserItem inside an Action. The datamodel doesn't look good when using with the Struts tag <s:property value="userItem.foo"/> . What I want to do is write a static util method Helper.printNice(Foo) that takes parameter Foo and prints out the value contained in Foo in a user-friendly display. How do I use the Struts property tag with the static method? Something like this com.helper.Helper.printNice(<s:property value="userItem

Displaytag struts 2 go to specific page

我的未来我决定 提交于 2019-11-28 06:36:33
问题 in my project i'm using display tag. The problem comes when the results returned are like e.g. 300 pages. The user needs to jump to page e.g. 200 but he can't. He needs to go slowly there ( 5 pages at a time or so ). I want to add the ability to the user to choose in a drop-down the page he wants to jump to. Is there any property in display-tag or any suggestion? 回答1: You need to use ParamEncoder to get the name (and eventually the value ) of displayTag 's parameters, specified in

Struts 2 refactoring code to avoid OGNL static method access

末鹿安然 提交于 2019-11-28 05:34:59
问题 Struts 2, 2.3.20 mentioned that Support for accessing static methods from expression will be disabled soon, please consider re-factoring your application to avoid further problems! We have used OGNL static calls in validators: @ExpressionValidator( expression = "@foo.bar@isValidAmount(amount)", key = "validate.amount.is.not.valid"), Also we used it in tags <s:set var="test" value="@foo.bar@sampleMethod(#attr.sampleObject.property1)" /> Well, what is the best way to refactor above two usages ?

What is wrong with headerKey=“-1”?

老子叫甜甜 提交于 2019-11-28 02:17:43
问题 What is wrong with: <s:select list="fruits" name="fruitSelect" id="fruitSelect" listKey="fid" listValue="fname" headerKey="-1" headerValue="Pick a fruit!" /> Plenty of online examples use this value: http://www.coderanch.com/t/439139/Struts/wrong-select http://www.mkyong.com/struts2/struts-2-sselect-drop-down-box-example/ BUT the actual documentation (you can view this on the tooltip in Eclipse by hovering over the symbol) says Key for first item in list. Must not be empty! '-1' and '' is