XXX cannot be resolved to a type

虽然class导入到了jsp, 仍会报错XXX cannot be resolved to a type

如  BitMatrix cannot be resolved to a type。

<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="com.google.zxing.*"%>
<%@ page import="java.io.*"%>
<%!
String getURLRoot(javax.servlet.http.HttpServletRequest request)
{
return request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
}
%>
<%
Enumeration enu=request.getParameterNames();
while(enu.hasMoreElements())
{
String paraName=(String)enu.nextElement();
System.out.println(paraName+": "+request.getParameter(paraName));
}

BitMatrix str = new BitMatrix(10);
%>

这是编译时找不到路径。

解决方法,导入时写class完全路径:

<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.google.zxing.common.BitMatrix"%>
<%@ page import="com.google.zxing.BarcodeFormat"%>
<%@ page import="com.google.zxing.EncodeHintType"%>
<%@ page import="com.google.zxing.MultiFormatWriter"%>
<%@ page import="com.google.zxing.client.j2se.MatrixToImageWriter"%>
<%!
String getURLRoot(javax.servlet.http.HttpServletRequest request)
{
return request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
}
%>
<%
Enumeration enu=request.getParameterNames();
while(enu.hasMoreElements())
{
String paraName=(String)enu.nextElement();
System.out.println(paraName+": "+request.getParameter(paraName));
}

String code_url = request.getParameter("code_url");
try
{
int width = 200;
int height = 200;
String format = "png";
Hashtable hints = new Hashtable();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix bitMatrix = new MultiFormatWriter().encode(code_url, BarcodeFormat.QR_CODE, width, height, hints);
OutputStream out1 = null;
out1 = response.getOutputStream();
response.setContentType("image/jpeg");
MatrixToImageWriter.writeToStream(bitMatrix, format, out1);
out1.flush();
out1.close();
}
catch (Exception e)
{
out.println(e.getMessage());
}
%>

时间: 2024-10-16 03:13:07

XXX cannot be resolved to a type的相关文章

xxx cannot be resolved to a type 错误解决方法

(1)jdk不匹配(或不存在)     项目指定的jdk为“jdk1.6.0_18”,而当前eclipse使用的是“jdk1.6.0_22”.需要在BuildPath | Libraries,中做简单调整.     (2)jar包缺失或冲突     当找不到“XX”所在的jar包时,会报这个错.解决只需要找到(ctrl+点击,可能能看到jar包名称)对应jar包导入项目即可.     另外,出现相同的XX时也会报此错.可能需要调包.解包.选删.     (3)eclipse查找项目类型策略所致

HttpServlet cannot be resolved to a type

Description Resource Path Location TypeHttpServlet cannot be resolved to a type SimpleServlet.java /JavaHelloWorldApp/src/main/java/wasdev/sample/servlet line 15 Java ProblemHttpServletRequest cannot be resolved to a type SimpleServlet.java /JavaHell

cannot be resolved to a type解决方法!!!

小楼今天在做一个Java项目的时候遇到一个大家经常遇到的问题:XXX cannot be resolved to a type 看到一百多个errors时的时候,小楼也是被吓得赶紧去找度娘. 归纳一下小楼在网上看到的这种报错的主要的几种原因: 1.jdk不匹配(或不存在) 2.jar包缺失或冲突 3.eclipse查找项目类型策略所致 相应的解决方案是: 1.jdk不匹配(或不存在)时:例如项目指定的jdk为“jdk1.6.0_18”,而当前eclipse使用的是“jdk1.6.0_22”.需要

The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....

遇到The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....,查找的解决办法如下: 一: 错误提示: It is indirectly referenced from required .class file 错误的解决 原因:你导入得jar依赖另一个jar 解决方法:导入缺失的包

The type xxx cannot be resolved. It is indirectly referenced from required .class files

项目A中引入一个jar包B,在项目A中调用项目B,出现如下错误提示: 大致意思是:这上面所需的包是间接引用的,即A项目调用B项目,B项目又引用了另外一个包C,而这个包现在不在你的A项目的引用中. 所以你需要做的就是把jar包C引入至项目A中. The type xxx cannot be resolved. It is indirectly referenced from required .class files

在eclipse中新建java问题报错:The type XXX cannot be resolved. It is indirectly referenced from required .class files

在Eclipse中遇到The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....,查找的解决办法如下: 一: It is indirectly referenced from required .class file 原因:你正要使用的类调用了另一个类,而这个类又调用了其他类,这种关系可能会有好多层.而在这个调用的过程中,某个类所在的包的缺失就会造成以上那个错误. 解

(转)eclipse报错及解决说明 &quot;XX cannot be resolved to a type &quot;

场景:在项目开发时,一个工程引用另一个工程中的文件,出现报错“XX cannot be resolved to a type”,但是在实际通过跟踪“F3”能够找到相应的文件,最终用方法4解决. 引言: eclipse新导入的项目经常可以看到“XX cannot be resolved to a type”的报错信息.本文将做以简单总结. 正文: 1 jdk不匹配(或不存在) 项目指定的jdk为“jdk1.6.0_18”,而当前eclipse使用的是“jdk1.6.0_22”.需要在BuildPa

cannot be resolved to a type in same package 问题解决

在 STS 上,一个类引用在相同 package 中另一个类,但是报 cannot be resolved to a type 错误. 解决方法 : Alternatively, you can highlight the project : Choose Clean ... from Project menu and if you have activated the Build Automatically option (in the same menu), the classes will

使用Maven创建Web项目后,jsp引入静态文件提示报错。JSP 报错:javax.servlet.ServletException cannot be resolved to a type

使用Maven创建Web项目后,jsp引入静态文件提示报错. 错误提示:javax.servlet.ServletException cannot be resolved to a type 错误如下图: 解决方案: 在Maven的pom文件中引发如下依赖即可: <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <versio