Struts.xml文件如下    <package name="portal" extends="struts-default">
<interceptors>
<interceptor name="loginfromsap"
class="com.hzj.portal.index.interceptor.LoginFromSapInterceptor" />

<interceptor name="authority"
class="com.hzj.portal.index.interceptor.AuthorityInterceptor" />
<interceptor-stack name="portaldefault">
<interceptor-ref name="basicStack"></interceptor-ref>
<interceptor-ref name="authority">
<param name="excludeMethods">login</param>
</interceptor-ref>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="basicStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="portaldefault"></default-interceptor-ref>
<global-results>
<result name="globalLogin">/fault.jsp</result>
<result name="myError">/myError.jsp</result>
<result name="queryIndex">/WEB-INF/portal/query/queryIndex.jsp</result>
<result name="xqjhSp">/WEB-INF/portal/grad/xqjhSp.jsp</result>
</global-results>


<action name="login_loginfromsap">
          <interceptor-ref name="loginfromsap" /><!-- sap登录用指定的拦截器 -->
        </action>
</package>           
    
url如下http://127.0.0.1:8080/pro/login_loginfromsap.action?forward=xqjhSp类里做了个跳转 try{ String forward = request.getParameter("forward");
if(forward == null) forward="globalLogin";
                           return forward;

}catch(Exception e){
request.setAttribute("exception", e);
        return "myError";
}报的错误信息如下18:36:26,729  WARN Dispatcher:49 - Could not find action or result
No result defined for action com.opensymphony.xwork2.ActionSupport and result xqjhSp
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:364)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)

解决方案 »

  1.   

    我不知道只是不是问题所在,但是是我的两点疑问:
    1.  <action name="login_loginfromsap">
           <interceptor-ref name="loginfromsap" /><!-- sap登录用指定的拦截器 -->
        </action>
        你拦截器不是放在最上面吗,那他一开始就会执行,这里又为什么要在写一便呢,有点浪费,直接写你的<result>不就可以了吗2.18:36:26,729  WARN Dispatcher:49 - Could not find action or result
    No result defined for action com.opensymphony.xwork2.ActionSupport and result xqjhSp 是没有找到这个xqjhSp,    而你的<result name="xqjhSp">/WEB-INF/portal/grad/xqjhSp.jsp</result>   在写路径时一般不带WEB-INF吧,他会自己默认找他的,要是在写一个的话,他会以为是WEB-INF下还有个文件夹叫WEB-INF
      

  2.   


    package com.hzj.portal.index.interceptor;import javax.annotation.Resource;
    import javax.servlet.http.Cookie;
    import javax.servlet.http.HttpServletRequest;import org.apache.struts2.StrutsStatics;import com.hzj.portal.constant.Constant;
    import com.hzj.portal.index.service.LoginService;
    import com.hzj.portal.index.vo.UserInfo;
    import com.hzj.portal.system.vo.UserDefineInfo;
    import com.mysap.sso.SSO2Ticket;
    import com.opensymphony.xwork2.ActionContext;
    import com.opensymphony.xwork2.ActionInvocation;
    import com.opensymphony.xwork2.interceptor.Interceptor;public class LoginFromSapInterceptor implements Interceptor{ private static final long serialVersionUID = 3010541593062421381L;
    private static final String sapLoginCookieName = "MYSAPSSO2";
    private ActionContext actionContext;
    private HttpServletRequest request; @Override
    public String intercept(ActionInvocation ctx) throws Exception{
    actionContext = ctx.getInvocationContext();
    request = (HttpServletRequest)actionContext.get(StrutsStatics.HTTP_REQUEST);


    String newCookieValue = getCookieValue(sapLoginCookieName);
    if(newCookieValue.equals("")){
    request.setAttribute("exception", new Exception("没有相关  cookie 值!"));
    return "myError";
    }else{
    //String oldCookieValue = (String)request.getSession().getAttribute("oldCookieValue");
    //if(!newCookieValue.equals(oldCookieValue)){//相同 ,那么是同一用户,不用再次解析;如果不相同那么是不同用户登录,需要重新解析
    //现在每次从 sap 过来都解析
    try{
    login(newCookieValue);
    request.getSession().setAttribute("oldCookieValue",newCookieValue);//更新老cookie 的值 String forward = request.getParameter("forward");
    if(forward == null) forward="globalLogin";
                return forward;

    }catch(Exception e){
    request.setAttribute("exception", e);
            return "myError";
    }
    }
    } public String getCookieValue(String cookieName){

    Cookie[] all_Cookies = request.getCookies ();
         String   ticket      = "";
        int      i           = 0;
        for (i=0; i<all_Cookies.length; i++) {
            if (cookieName.equals (all_Cookies[i].getName ())) {
                ticket = all_Cookies[i].getValue ();
                break;
            }
        }
        return ticket;
    }



    public void login(String sapLoginCookieValue) throws Exception{
    //System.out.println(System.getProperty("java.library.path"));tomcat 环境下和 普通 java 平台下的 java.library.path 变量的值不一样
    String sapsecuFileName =null;
    if (System.getProperty("os.name").startsWith("Win"))  {
    sapsecuFileName = "sapsecu.dll";
            } else {
             sapsecuFileName = "libsapsecu.so";
            }

    SSO2Ticket.init(sapsecuFileName);//dll 文件需要放在tomcat 安装目录 bin 文件夹下,或者指定绝对路径
    String verifyFileName = "verify.pse";
    String verifyPath = this.getClass().getClassLoader().getResource(verifyFileName).toString().substring(6);//需要去掉"file:/"
    Object o[];
    o = SSO2Ticket.evalLogonTicket(sapLoginCookieValue,verifyPath , null);

        String user   = "";
        String Sysid  = "";
        String Client = "";
        String PrtUsr = ""; if (o!=null) {
            user   = (String)o[0]; //First element is the SAP system user
            Sysid  = (String)o[1]; //Second element is the id of the issuing system
            Client = (String)o[2]; //Third element is the client of the issuing system
            PrtUsr = (String)o[4]; //Portal user
    }

    user = user.replaceFirst("0*", "");
    //user="321";
    UserDefineInfo userDefineInfo = loginService.getLoginUser(user);
    if(userDefineInfo == null){
    throw new RuntimeException("用户"+user+"不存在!");
    }
    UserInfo userInfo=new UserInfo();
    userInfo.setUser(userDefineInfo);

    request.getSession().setAttribute(Constant.USER_SESSION_KEY, userInfo);
    userInfo.setModuleList(loginService.findUserModuleList(Long.valueOf(user).longValue()));
    }

    @Resource(name = "LoginServiceImpl")
    private LoginService loginService; @Override
    public void destroy() {
    // TODO Auto-generated method stub

    } @Override
    public void init() {
    // TODO Auto-generated method stub

    }
    }
      

  3.   

     Could not find action or result
    No result defined for action com.opensymphony.xwork2.ActionSupport and result xqjhSp错误信息说的很是明白action配置错了
      

  4.   

    action 不是已经配置上<result name="xqjhSp">/WEB-INF/portal/grad/xqjhSp.jsp</result>  
      

  5.   

    xqjhSp.jsp如下
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ include file="/common/taglibs.jsp"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
    </head><body>
    <div style="text-align:center">
    <div style="width:1000px;height:700px">
      <iframe src="${portal}/grad/GradAction_findAll.action" id="id" name="name" style="width:100%;height:100%"></iframe>
    </div>
    </div>
    </body>
    </html>struts.xml<?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <package name="grad" namespace="/grad" extends="portal">
      
    <action name="GradAction_*" class="com.hzj.portal.grad.action.GradAction" method="{1}">
                <result name="FindAll">/WEB-INF/portal/grad/GradListShow.jsp</result>
             </action>
    </package>
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    </struts>
      

  6.   

    这错误也太明显了
    http://127.0.0.1:8080/pro/login_loginfromsap.action?forward=xqjhSp
    这个URL传递的参数forward=xqjhSp
    而你的action中的逻辑是
    String forward = request.getParameter("forward");
    if(forward == null) {
       forward="globalLogin";
    }
    return forward;
    ××××××××××××××××××××
    执行这个URL,得得forwar参数肯定不为空
    那么你最后return的forward=xqjhSp这个result在struts.xml中根本就没有配置,当然跑异常
      

  7.   


    人家那么大一行
     <result name="xqjhSp">/WEB-INF/portal/grad/xqjhSp.jsp</result>  
      

  8.   

    <result name="xqjhSp">/WEB-INF/portal/grad/xqjhSp.jsp</result>
    干掉试试。