请各位大虾帮忙找找这个jsp调用java的错误

问题描述:
我在jsp页面导入<%@ page import="com.jerry.action.test.TestAction" %>
并且实列化该类,TestAction test = new TestAction();
但是如果我以 test.test2()去调用该类中的test()方法就会抛出 Generated servlet error:A cannot be resolved to a type。


<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="com.jerry.action.test.TestAction" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>手机下载网</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<%
TestAction action = new TestAction();
A aa=new A();
aa.aa();
//action.test();
System.out.println("**************count*****:"+TestAction.class);

%>
<body>
<br><br>欢迎你,测试成功!<br>
</body>
</html>




package com.jerry.action.test;

import java.util.List;

import com.jerry.manager.test.TestManager;
import com.jerry.model.UserInfo;

public class TestAction {

public final int jerry=10;
public static int aa=122;
public TestManager testManager;

public List getTestMessage(){
return testManager.getObjects(UserInfo.class);
}
public void test(){
//testManager.test();
}

public void test2(){
System.out.println("****************test********************");
}
public void setTestManager(TestManager testManager) {
this.testManager = testManager;
}
}

Java 调用第三方 API 接口需要以下步骤: 1. 了解 API 文档:首先需要了解第三方 API 的使用文档,包括 API 接口地址、求参数、返回参数等信息。 2. 创建 URL 对象:根据 API 文档中提供的接口地址,使用 Java 的 URL 类创建一个 URL 对象。 3. 打开连接:使用 URL 对象调用 openConnection() 方法打开一个连接。 4. 设置求参数:根据 API 文档中提供的求参数,设置求头、求方法、求参数等信息。 5. 发送求:使用连接对象的 getOutputStream() 或者 getInputStream() 方法发送求数据或获取响应数据。 6. 解析返回结果:根据 API 文档中提供的返回参数,解析响应数据并进行处理。 以下是一个简单的 Java 调用第三方 API 的示例代码: ```java import java.net.*; import java.io.*; public class ApiTest { public static void main(String[] args) { try { // 创建 URL 对象 URL url = new URL("https://api.example.com/api/v1/user"); // 打开连接 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); // 设置求参数 conn.setRequestMethod("GET"); conn.setRequestProperty("Authorization", "Bearer xxxxxxxx"); // 发送求 InputStream inputStream = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line; StringBuffer response = new StringBuffer(); while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // 解析返回结果 System.out.println(response.toString()); } catch (Exception e) { e.printStackTrace(); } } } ``` 注:以上代码仅供参考,实际使用需要根据具体的 API 文档进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值