解决方案 »

  1.   

      <form name="form1" action="loginAction.action" method="post">不建议写相对路径的。如果对路径理解不清晰的话,经常出错。
      

  2.   

    action="loginAction.action",action加上你的项目访问路径,如:你项目的访问路径是test,那就改成:/test/loginAction.action,看看你server.xml里面配置的context下的path
      

  3.   

       按楼上的建议写成这种形式不行:
    <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中没有配置对,所以找不到了!
      

  4.   

    你Action里面的方法是用的execute()
      

  5.   

    配置没问题,这个错误提示说明loginAction.action 不是被当做一个Action处理的,而是当做路径处理的,和.jsp一样,个人觉得是在过滤器里面出现问题了
    个人意见
      

  6.   

    Web.xml配置了StrutsServet???
    没有这个Servlet怎么转发你的请求?
      

  7.   

    楼上说loginAction.action 不是被当做一个Action处理的,而是当做路径处理的
    麻烦给看看过滤器是那个地方处理的有问题!
    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;
    }
    }
      

  8.   

    其实要看是不是拦截器出了错误,只要把struts的拦截器卸载web.xml文件的最上面就行了,web.xml的读取顺序是从上到下的。如果能成功运行,就说明是LoginFilter这个拦截器出问题啦
      

  9.   

    补充一下,web.xml读取从上到下是针对同种类型的标签的,比如<filter-mapping>
      

  10.   

    在web.xml中把loginFilter已经注释掉,现在可以直接访问到loginAction了,还是报错!HTTP Status 404 - /oa/loginAction.action--------------------------------------------------------------------------------type Status reportmessage /oa/loginAction.actiondescription The requested resource is not available.
    --------------------------------------------------------------------------------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>
      

  11.   

    貌似没有在你的web.xml中没有看到你的servlet配置,你如何转发...
      

  12.   

    我用的spring的全注解和struts2,这个应该不需要在web.xml中配置servlet吧!