0

我正在尝试使用 SDK 附带的 eBay 示例应用程序(签名重定向)。

我已将应用程序复制到 webapps 目录并进行了适当的更改以使其运行。

现在我收到了这个错误。

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 16 in the generated java file
Only a type can be imported. signinredirect.Global resolves to a package

An error occurred at line: 18 in the jsp file: /credentials.jsp
Global cannot be resolved
15:   String signInURL = ""; 
16:   String ApiServerUrl = "";
17:   String reqError ="";
18:   String devId = Global.getProperty("devId");
19:   String certId = Global.getProperty("certId");
20:   String appId = Global.getProperty("appId");
21:   //runame of this sample application

jsp代码:

<html>
<head>
<title>
eBay signin redirection sample with new token fetch flow
</title>
</head>
<body bgcolor="#ffffff">
<%@ page import="com.ebay.sdk.*" %>
<%@ page import="com.ebay.sdk.call.*" %>
<%@ page import="signinredirect.Global" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page errorPage="errorPage.jsp" %>

<%
  String signInURL = ""; 
  String ApiServerUrl = "";
  String reqError ="";
  String devId = Global.getProperty("devId");
  String certId = Global.getProperty("certId");
  String appId = Global.getProperty("appId");
  //runame of this sample application
  String runame = Global.getProperty("runame");

  if (request.getParameter("goToSignin") != null ) {
        reqError="";

        int environment = Integer.parseInt(request.getParameter("EnvList"));
        if (environment == 1 ) {
            // Sandbox
            signInURL =Global.getProperty("sandboxSignInUrl");
            ApiServerUrl = Global.getProperty("sandboxAPIUrl");

        } else if (environment ==2) {
            // Production
            signInURL = Global.getProperty("ebaySignInUrl");
            ApiServerUrl = Global.getProperty("ebayAPIUrl");

        }

        //Get the Credentials Information 
        devId = request.getParameter("DevID");
        if(devId.length() == 0 )
         throw new SdkException("Please enter developer ID.");
        appId  = request.getParameter("AppID");
        if( appId.length() == 0 ) 
         throw new SdkException("Please enter application ID.");
        certId = request.getParameter("CertID");
        if( certId.length() == 0 ) 
         throw new SdkException("Please enter certificate ID.");
        //Get the runame
        runame = request.getParameter("RuName");
        if(runame.length() == 0)
         throw new SdkException("Please enter runame of the sample application");


        ApiContext apiContext = Global.createApiContext(devId, appId, certId, ApiServerUrl );
        ApiLogging apiLogging = new ApiLogging();
        apiContext.setApiLogging(apiLogging);
        session.setAttribute("apicontext", apiContext );

        GetSessionIDCall api = new GetSessionIDCall(apiContext);
        api.setRuName(runame);

        String ruParams="params="+runame +"-"+(environment==1?"Sandbox":"Production");

        try {

             String sessionID = api.getSessionID();
             String encodedSesssionIDString =URLEncoder.encode(sessionID,"UTF-8");           

             session.setAttribute("sessionID", sessionID);           
             response.sendRedirect(response.encodeRedirectURL(signInURL + "&RuName=" + runame + "&SessID=" + encodedSesssionIDString + "&ruparams=" + ruParams));     

        } catch(SdkHTTPException ex) {
            reqError = "Call failed: " + ex.getMessage();
        } catch(Exception ex) {
            reqError = ex.getMessage();
        } 
}
%>

Java 类 Global 存在。看来导入失败了。有人能告诉我我做错了什么吗?

4

2 回答 2

2

这意味着 signinredirect.Global 是一个包,而不是一个类。试试这个:

<%@ page import="signinredirect.Global.*" %>
于 2013-02-24T21:52:32.617 回答
1

我必须创建一个新的 Web 应用程序项目,而不是从 sdk 复制示例应用程序。

于 2013-02-24T22:57:29.407 回答