解决方案 »
- struts2中如何改变表单标签的大小和字体?
- ipad iframe 读取pdf
- Spring-Security 中的资源访问安全和方法执行安全如何共享 accessDecisionManager ?
- struts 1.3如何实现跨目录的跳转,在线等......急?
- JSP数据库表格操作
- 急救,ChartDirector,报酬 500元话费
- 编译JSP(2600行)时出现"编码过大"的错误,请问是什么原因,有办法解决吗
- 编码问题~简单大家来拿分吧~
- 请问我的.txt文件应该放在什么地方?????
- 论坛中帖子是用Message, 短消息的英文单词是什么?
- 求救这种框架或者架构是什么
- ZK 框架的 ckeditor 有时候能得到内容有时候得不到
<form name="form1" action="${pageContext.request.contextPath}/loginAction.action" method="post">写成这样也不行:
<form name="form1" action="/TSP/loginAction.action" method="post">从报错来看,我怀疑是struts.xml的问题,是不是我的action在struts.xml中没有配置对,所以找不到了!
个人意见
没有这个Servlet怎么转发你的请求?
麻烦给看看过滤器是那个地方处理的有问题!
loginFilter的代码如下:
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;import com.bonsoft.oa.util.Constants;
import com.bonsoft.oa.util.session.*;public class LoginFilter implements Filter {
private FilterConfig config;
protected final Log logger = LogFactory.getLog(getClass());
private String excluded;
private static final String EXCLUDE = "exclude";
private boolean no_init = true; // private LoginServlet loginServlet;
public void setFilterConfig(FilterConfig paramFilterConfig) {
if (this.no_init) {
this.no_init = false;
this.config = paramFilterConfig;
if ((this.excluded = paramFilterConfig.getInitParameter("exclude")) != null)
this.excluded += ",";
}
} private String getActionName(String actionPath) {
logger.info("filter actionPath===="+actionPath);
StringBuffer actionName = new StringBuffer();
try {
int begin = actionPath.lastIndexOf("/");
if (begin >= 0) {
actionName.append(actionPath.substring(begin, actionPath.length()));
}
} catch (Exception e) {
}
return actionName.toString();
} private boolean excluded(String paramString) {
logger.info("paramString====" + paramString);
logger.info("excluded====" + this.excluded);
logger.info(this.excluded.indexOf(paramString + ",")+"*********");
if ((paramString == null) || (this.excluded == null))
return false;
return (this.excluded.indexOf(paramString + ",") >= 0);
} public void destroy() {
// TODO Auto-generated method stub } public void doFilter(ServletRequest request, ServletResponse response, FilterChain arg2) throws IOException,
ServletException {
logger.info(request.getProtocol()); HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
String url = req.getRequestURI();
String actionName = getActionName(url);
logger.info("actionname===="+actionName);
String login = req.getContextPath() + "/jsp/zh_CN/login/login.jsp";
if (!excluded(actionName)) {
logger.info("not the exclude name..................");
UserSessionInfo userSessionInfo = (UserSessionInfo) req.getSession().getAttribute(Constants.USER_SESSION);
if (userSessionInfo == null) {
logger.info("session null.............");
resp.sendRedirect(login);
return;
}
}
try {
arg2.doFilter(request, response);
} catch (Exception e) {
logger.error("LoginFilter Fail:" + e.getMessage(), e);
}
} public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
this.config = arg0;
if ((this.excluded = arg0.getInitParameter("exclude")) != null)
this.excluded += ",";
this.no_init = false;
}
}
--------------------------------------------------------------------------------Apache Tomcat/7.0.47不能确认问题出在什么地方了!
是struts.xml配置的问题,还是action路径的问题?
求高手解答!谢谢了!
struts.xml配置如下:<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<include file="struts-default.xml" />
<package name="web" extends="struts-default">
<global-results>
<result name="error">/jsp/zh_CN/error/syserror.jsp
</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="error" exception="java.lang.Exception" />
</global-exception-mappings>
<action name="loginAction" class="com.oa.login.action.LoginAction">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>