Tag: interceptorstack

当向其他人重定向(带拦截器)动作时,Struts2动作无法执行

我向ActLand发送请求,然后intercept() ,如果没有登录,则重定向到Login.jsp 。 struts.xml : /login.jsp /index.jsp /index.jsp /login.jsp 拦截器: public class LoginInterceptor extends AbstractInterceptor { @Override public String intercept(final ActionInvocation invocation) throws Exception { Map session = ActionContext.getContext().getSession(); int userId = -1; if (session.get(“userId”) != null) { userId = Integer.parseInt(session.get(“userId”).toString()); } Object action = invocation.getAction(); if (userId < 0) { return "loginRedirect"; } else […]

struts2让我发疯了

我一直在努力创建一个java项目。 它使用Struts 2标签。 无论何时单击按钮都会有更新 ,它应该更新数据库中的值。 但是我收到了这个错误: 没有为动作com.comviva.im.ui.action.sysadmin.CUGAction和结果输入定义结果

在Struts 2中获取拦截器参数

我有以下动作映射 … one two … nth-number … 我可以在Interceptor中使用以下行获取参数映射 Map params = ActionContext.getContext().getParameters(); 如上所述, 有没有办法获得下面的映射中定义的拦截器参数 。 … one two … nth-number … 并且动作参数以下面的方式定义,动作参数和拦截器参数应该可以单独访问。 … one two … nth-number …. one two … nth-number … 请注意,我不想在拦截器中声明参数字段 //all fields with their getters and setters private String param1; private String param2; … private String paramN; 在Dev Blanked’s asnwer之后,我实施了他的技术。 它没有用,所以我在这里分享我的代码。 […]

Struts2 Fileupload在动作类中给出null文件

我正在尝试使用struts2 fileUpload拦截器在我的Web应用程序中实现文件上载过程。 下面是我的代码 的index.jsp 在struts.xml 1024000 application/pdf /viewChapters.jsp FileUploadAction.java public class FileUploadAction extends ActionSupport { private File fileUpload; private String contentType; private String fileName; private String destPath; /// setter and getter methods public String execute() { destPath=”C:\\WebPortal_testing”; try { System.out.println(“Source File Name:”+fileUpload); System.out.println(“Destination File Name:”+fileName); File destFile= new File(destPath,fileName); FileUtils.copyFile(fileUpload, destFile); } catch(IOException exception) { […]

在Struts 2中使用拦截器时出现NullPointerException

这是我的WelcomeAction类 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=ab; break; case ‘3’: sum=a*b; break; case ‘4’: try { sum=a/b; } catch(ArithmeticException ae) […]