struts2-interceptors

Fill a form with saved cookies

 ̄綄美尐妖づ 提交于 2019-11-30 08:55:42
问题 I have an action class that saves my cookies like this: public String execute() { // Save to cookie Cookie name = new Cookie("name", userInfo.getName() ); name.setMaxAge(60*60*24*365); // Make the cookie last a year! servletResponse.addCookie(name); } If I submit my form, I can see the cookies on the browser that has been created and saved. When the user submits, they get redirected to a new page, a page with all the stored information that they just created. I want the user to be able to go

Parameters with no mutators and accessors (setters/getters) along with the parameters interceptor in Struts 2

三世轮回 提交于 2019-11-29 10:31:26
In the following action class, I'm using the parameters interceptor. @Namespace("/admin_side") @ResultPath("/WEB-INF/content") @ParentPackage(value = "struts-default") @InterceptorRefs(@InterceptorRef(value="store", params={"operationMode", "AUTOMATIC"})) public final class TestAction extends ActionSupport implements Serializable, ValidationAware, Preparable { private static final long serialVersionUID = 1L; private String param1; private String param2; //Getters and setters. public TestAction() {} @Action(value = "TestMessage", results = { @Result(name=ActionSupport.SUCCESS, type=

Fill a form with saved cookies

拜拜、爱过 提交于 2019-11-29 08:58:22
I have an action class that saves my cookies like this: public String execute() { // Save to cookie Cookie name = new Cookie("name", userInfo.getName() ); name.setMaxAge(60*60*24*365); // Make the cookie last a year! servletResponse.addCookie(name); } If I submit my form, I can see the cookies on the browser that has been created and saved. When the user submits, they get redirected to a new page, a page with all the stored information that they just created. I want the user to be able to go back to the submit page and see all the information in the forms that they just submitted. Is it

Date Conversion in Struts2 [closed]

自闭症网瘾萝莉.ら 提交于 2019-11-27 23:23:22
I am wondering how to convert a String to Date in Struts2. I have a simple form in which user provide the date in this format "yyyy-MM-dd" . Upon submit the Sturts2 maps form that to the bean. I got error in date conversion. I Google it a lot and every where it is stated that we have to use custom type converter for this. I don't want to write a custom type converter for date conversion. I think there should be an easy mechanism in Struts2 for data conversion because data conversion is very common functionality. JSP <s:form action="AddDomain"> <s:push value="idp"> <s:textfield name="domainName

NullPointerException when uploading a file

倾然丶 夕夏残阳落幕 提交于 2019-11-27 16:23:10
When uploading a file, I get the following error: Struts Problem Report Struts has detected an unhandled exception: Messages: File: java/io/File.java Line number: 317 Stacktraces java.lang.NullPointerException java.io.File.(File.java:317) example.uploadFile.execute(uploadFile.java:36) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav‌​a:43) java.lang.reflect.Method.invoke(Method.java:483) index.jsp <form action="upload" method=

User session getting mixed up on tomcat

旧时模样 提交于 2019-11-26 23:17:53
问题 We are using Tomcat 6.29 behind IIS7.5, with spring, hibernate and struts2 framework. We are now beginning to notice that the server sessions are getting mixed up especially in Ajax request. More details about the problem User 1 requests page1, user 2 request page2. But user1 gets served page2 and user2 gets server page1. The session ids are also changing, but on refreshing the page, the correct page is served up. The problem seems to be happening more often when the number of users are high.

Unexpected Exception caught setting 'xxx' on 'class xxx: Error setting expression 'xxx' with value ['x', ]

馋奶兔 提交于 2019-11-26 22:31:03
I'm passing some parameters to an action class implementing ModelDriven<Transporter> through a query-string. <s:form namespace="/admin_side" action="Test" id="dataForm" name="dataForm"> <s:url id="editURL" action="EditTest" escapeAmp="false"> <s:param name="transporterId" value="1"/> <s:param name="transporterName" value="'DHL'"/> </s:url> <s:a href="%{editURL}">Click</s:a> </s:form> The action class is as follows. @Namespace("/admin_side") @ResultPath("/WEB-INF/content") @ParentPackage(value = "struts-default") public final class TestAction extends ActionSupport implements Serializable,

i18n Interceptor usage in Struts2

老子叫甜甜 提交于 2019-11-26 21:41:38
问题 I want to make a site multilingual. I have an normal interceptor stack which contains <interceptor-ref name="i18n" /> A common jsp for changing locale: <s:a action="locale-manager" namespace="/common"> <s:param name="request_locale">fa_IR</s:param> فارسی </s:a> <s:a action="locale-manager" namespace="/common"> <s:param name="request_locale">en_US</s:param> English </s:a> And a simple LocaleManager action public class LocaleManager extends ActionSupport{ private static final Logger log =

Unexpected Exception caught setting &#39;xxx&#39; on &#39;class xxx: Error setting expression &#39;xxx&#39; with value [&#39;x&#39;, ]

耗尽温柔 提交于 2019-11-26 08:23:21
问题 I\'m passing some parameters to an action class implementing ModelDriven<Transporter> through a query-string. <s:form namespace=\"/admin_side\" action=\"Test\" id=\"dataForm\" name=\"dataForm\"> <s:url id=\"editURL\" action=\"EditTest\" escapeAmp=\"false\"> <s:param name=\"transporterId\" value=\"1\"/> <s:param name=\"transporterName\" value=\"\'DHL\'\"/> </s:url> <s:a href=\"%{editURL}\">Click</s:a> </s:form> The action class is as follows. @Namespace(\"/admin_side\") @ResultPath(\"/WEB-INF