interceptorstack

NullPointerException when using an interceptor in Struts 2

与世无争的帅哥 提交于 2019-12-01 10:45:10
问题 This is my WelcomeAction Class package com.codinghazard.actions; public class WelcomeAction { private String operandA; private String operandB; private Character operator; private int sum; public String execute() { if ((operandA!="") && (operandB!="")) { int a=Integer.parseInt(operandA); int b=Integer.parseInt(operandB); switch (operator) { case '1': sum=a+b; break; case '2': sum=a-b; break; case '3': sum=a*b; break; case '4': try { sum=a/b; } catch(ArithmeticException ae) { return "ERROR"; }

Struts 2: excluding method from validation from just the defaultStack interceptor

不羁的心 提交于 2019-12-01 06:47:54
I want to be able to disable form validation for one action in Struts 2, but have the rest of the interceptor stack still be able to run. I have an interceptor that checks to see if the user is logged in, which I always want execute, but for some actions (inputting information, for instance), I don't want the action's validate to be called. I tried doing something like the following: <interceptors> <interceptor name="bankingAuthenticator" class="csc309.a4.banking.BankUserAuthenticator"/> <interceptor-stack name="secureBanking"> <interceptor-ref name="bankingAuthenticator"/> <interceptor-ref

how to use fileUpload Interceptor along with other Interceptor Stack?

£可爱£侵袭症+ 提交于 2019-11-29 12:47:08
Here is my struts.xml configuration file in which I have a login interceptor. I want to use different file upload interceptor, in different action with different file type, and maximum size as given. But the problem is here: It's always taking the default maximumSize and allowedType . Plz help me where I am doing wrong? <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name=

Changing parameters after bind in Struts 2

有些话、适合烂在心里 提交于 2019-11-27 15:21:05
I have an action that receives some parameters from user (e.g. date). This action produces many different reports, so it has many different methods. I need to tune those parameters (set a time to midnight) before every method. The prepare method is executed before parameters are bound. Is there any other interceptor or any other convention that allows me to do that? Use the <interceptor-ref name="paramsPrepareParamsStack"/> <!-- An example of the params-prepare-params trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare

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,

Changing parameters after bind in Struts 2

喜欢而已 提交于 2019-11-26 18:29:44
问题 I have an action that receives some parameters from user (e.g. date). This action produces many different reports, so it has many different methods. I need to tune those parameters (set a time to midnight) before every method. The prepare method is executed before parameters are bound. Is there any other interceptor or any other convention that allows me to do that? 回答1: Use the <interceptor-ref name="paramsPrepareParamsStack"/> <!-- An example of the params-prepare-params trick. This stack

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