java - 无法编译 JSP 类(eBay 交易 API 示例 - 登录重定向)

标签 java jsp web-applications tomcat7 ebay-api

我正在尝试使用 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。看来导入失败了。有人可以告诉我我可能做错了什么吗?

最佳答案

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

<%@ page import="signinredirect.Global.*" %>

关于java - 无法编译 JSP 类(eBay 交易 API 示例 - 登录重定向),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15057021/

相关文章:

java - 使用 IntelliJ IDEA 调试时如何解析 JSP 中的 Spring 模型变量?

jsp - JSP标记文件: Exception inside of <c:set> results with a blank screen if it is executed inside of a tag file's body stored in a variable

python - WebJob Python 错误 ImportError : Missing required dependencies ['numpy' ]

web-applications - 用于创建网站导览的 Web App

java - 在java中实现类似的接口(interface)

java - 带有 google-api-java-client 的 2-legged OAuth

java - 无法使用最新的 OpenStack 验证 Swift ContextBuilder

java - JSP解析错误

java - ListIterator 抛出 "Exception in thread "main“java.util.ConcurrentModificationException”Java

php - 在 Web 应用程序中查找瓶颈的方法有哪些?