struts-validation

struts2 conventions plugin not working properly

自闭症网瘾萝莉.ら 提交于 2019-12-06 06:16:06
问题 I was trying to run the application with convention plugin Struts2. The application was fine with struts.xml configured like this: <struts> <package name="struts2demo" extends="struts-default"> <action name="hey" class="action.CountryAction" method="get"> <result name="success">/index.jsp</result> </action> <action name="add" class="action.CountryAction" method="add"> <result type="redirect" name="success">hey</result> </action> <!-- Add your actions here --> </package> </struts> now I

Struts 2 Download - How to configure the file name dynamically?

ぃ、小莉子 提交于 2019-12-05 07:48:08
I am developing one application , where people will download the required file from a location mentioned in the DB to their Local. I am using struts 2 for downloading the file from the server . I can download the file without any exception and it works perfectly. But the files am download has the filename i specified in struts.xml , i want it to be the exact filename which am downloading . example if the original file name is struts.pdf , i am downloading it as download.pdf, how to prevent it and download the file with actual filename My struts.xml configuration as follows , <action name=

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)

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

Basic flow of Struts

时间秒杀一切 提交于 2019-12-03 01:45:21
问题 Well I want to study Struts so I am going to begin with Struts 1, I would like to know the general flow. What files are required? Whats the function of struts-config.xml? validation.xml? validation-rules.xml When you visit your JSP page, and an action gets fired, what happens? What does the Action and Form class do? Which class is called first when an action gets fired. I just downloaded a sample form, and all these files are confusing at first. I would like to know whats going on to get a

Basic flow of Struts

点点圈 提交于 2019-12-02 15:19:00
Well I want to study Struts so I am going to begin with Struts 1, I would like to know the general flow. What files are required? Whats the function of struts-config.xml? validation.xml? validation-rules.xml When you visit your JSP page, and an action gets fired, what happens? What does the Action and Form class do? Which class is called first when an action gets fired. I just downloaded a sample form, and all these files are confusing at first. I would like to know whats going on to get a better idea of Struts. You should start with a tutorial on Struts, that will make it easy to understand

Avoid Return “input” Automatically in Struts

Deadly 提交于 2019-11-29 12:29:59
There is no problem when the action configuration in struts.xml is like this: <action name="customer-form"> <result name="success" type="tiles">/customer.tiles</result> </action> The problem comes when I access the action class on action configuration (struts.xml). I access the class before displaying the form because I want the dropdown option in the form to display the appropriate value as I instantiate it in action class. But it turns out, it will return "input" and I must handle it. method in action class: public String addCusto(){ custoType = new ArrayList<String>(); custoType.add("ABC");

Struts 2 - reusing Custom Expression Validator

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 06:33:01
问题 In struts 2 we can develop @CustomValidator which can be used in application wide @CustomValidator(type = "CustomerNumberValidator", fieldName = "customerNo") For validation MORE THAN ONE FIELD we use @ExpressionValidator @ExpressionValidator(expression = "( (!''.equals(account.firstName) && (!''.equals(account.lastName) ) || (presonalAccount == false)", key = "validate.account.name") If the expression is too complicated and needs to work on MORE THAN ONE FIELD we use OGNL to call static