struts2-interceptors

Why the Exception raised from my Interceptor is not caught by <global-exception-mappings>?

人走茶凉 提交于 2019-12-06 10:21:11
I have a custom Interceptor, from which I throw an Exception; The Action(s) running that Interceptor is managed by Convention plugin; The Exception raised by the Interceptor is globally defined in struts.xml for the package the Action is running into. RESULT: the exception mapping is ignored and I get the Struts Problem Report Struts has detected an unhandled exception: ... Stacktraces java.lang.IllegalArgumentException: my message I guess I'm just missing something stupid... we've already discussed of this in a similar question , but it's still not clear if it can or can't work this way:

Struts 2 - Understanding the working between OGNL and params interceptor

醉酒当歌 提交于 2019-12-06 04:43:30
I am new to Struts 2. I am studying it from the book Struts2 In Action. I am having difficulty in understanding some concepts in OGNL which are as follows- We know that params interceptor moves the data from the request parameters to the action object in ValueStack . Now while reading, I came upon a line that says- "The tricky part of the job is mapping the name of the parameter to an actual property on the ValueStack . This is where OGNL comes in. The params interceptor interprets the request parameter name as an OGNL expression to locate the correct destination property on the ValueStack".

How to have URLs without a suffix (e.g .action) in Struts 2?

末鹿安然 提交于 2019-12-05 02:39:15
问题 Here's the thing, I need to not only serve java, but also some javascript files, with my .war. So e,g. if someone goes to the URL: example.com/js/foo.jar Then I need that to be properly served as a javascript file. At the same time, if someone goes to: example.com/bar I need that to be served by Struts2 as a possible controller. The methods I've found online of removing the suffix from the url, would cause both URls to be served by struts 2 (and hence give an error for the first foo.js file

Struts 2 Validation using Message Store Interceptor

家住魔仙堡 提交于 2019-12-05 02:08:56
问题 I have an action where I am trying to log the user in. public class RegisteredUserAction extends ActionSupport implements SessionAware { .. .. public String login() throws Exception { DBLogic dBLogic = new DBLogic(); RegisteredUser user = null; try { user = dBLogic.getRegisteredUser(getUserUsername(), getUserPassword()); } catch (CredentialException e) { addFieldError("userUsername", e.getMessage()); addActionError(e.getMessage()); return INPUT; } if (user != null) { session.put("user", user)

Retaining values between multiple JSPs and Actions in Struts 2

余生颓废 提交于 2019-12-04 19:02:09
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 ActionSupport { private int txtid; //getter and setter @Override public String execute() throws Exception {

How to have URLs without a suffix (e.g .action) in Struts 2?

半世苍凉 提交于 2019-12-03 17:29:12
Here's the thing, I need to not only serve java, but also some javascript files, with my .war. So e,g. if someone goes to the URL: example.com/js/foo.jar Then I need that to be properly served as a javascript file. At the same time, if someone goes to: example.com/bar I need that to be served by Struts2 as a possible controller. The methods I've found online of removing the suffix from the url, would cause both URls to be served by struts 2 (and hence give an error for the first foo.js file even though it exists). Is there a way (such as an interceptor) which will first check if the given .js

Struts 2 Validation using Message Store Interceptor

淺唱寂寞╮ 提交于 2019-12-03 16:29:48
I have an action where I am trying to log the user in. public class RegisteredUserAction extends ActionSupport implements SessionAware { .. .. public String login() throws Exception { DBLogic dBLogic = new DBLogic(); RegisteredUser user = null; try { user = dBLogic.getRegisteredUser(getUserUsername(), getUserPassword()); } catch (CredentialException e) { addFieldError("userUsername", e.getMessage()); addActionError(e.getMessage()); return INPUT; } if (user != null) { session.put("user", user); return SUCCESS; } return ERROR; } } As you can see, if the username or password is invalid, I throw a

struts2 validation and prepare method related

泪湿孤枕 提交于 2019-12-02 18:32:55
问题 In have a custprofileview Action which show a JSP page with all details of customer and in my JSP all fields are like my <s:textfield name="custprofileVO.email" value="%{custprofileVO.email}" /> <s:textfield name="custprofileVO.phone" value="%{custprofileVO.phone}" /> and do so on, and there is a submit button that calls Action updatecustprofile . In updatecustprofile Action, instead of directly mapping properties I have a member variable private CustprofileVO custprofileVO; with setter and

struts2 making me go mad

旧城冷巷雨未停 提交于 2019-12-02 01:26:16
I have been trying to make a java project. Its using Struts 2 tags. There is a button Update whenever it is to be clicked, it should update the values in the database. But I am getting this error: No result defined for action com.comviva.im.ui.action.sysadmin.CUGAction and result input Andrea Ligios No result defined for action com.comviva.im.ui.action.sysadmin.CUGAction and result input This means that you are lacking the mapping for the input result for this Action in your Struts.xml The standard workflow JSP -> Interceptor Stack -> Action is breaking BEFORE reaching the Action, most likely

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"; }