相框代码,可编译,执行报错,进来帮忙分析下

coveking 2010-01-18 11:18:25

<%@page import="java.awt.*"%>
<%@page import="java.awt.image.*"%>
<%@page import="com.sun.image.codec.jpeg.*"%>
<%@page import="javax.imageio.*" %>


public static void addPhotoFrame (String framPicName, String srcPicName, String outputPicName) throws Exception {
//相框文件
File framePicFile = new File(framPicName);
Image framePic = ImageIO.read(framePicFile);
int width = framePic.getWidth(null);
int height = framePic.getHeight(null);
BufferedImage image=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.drawImage(framePic, 0, 0, width, height, null);
//原图片文件
File srcPicFile = new File(srcPicName);
Image srcPic = ImageIO.read(srcPicFile);
int srcWidth = srcPic.getWidth(null);
int srcHeight = srcPic.getHeight(null);
g.drawImage(srcPic, 0, 6, srcWidth, srcHeight, null);
g.dispose();
FileOutputStream out = new FileOutputStream(outputPicName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(image);
out.close();
}
addPhotoFrame("2.jpg","1.jpg","3.jpg");

...全文
119 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunny936 2010-01-18
  • 打赏
  • 举报
回复
328: List photos = element.getChildren("Photos");

有问题
coveking 2010-01-18
  • 打赏
  • 举报
回复
上面这段代码是单独可执行的,跟期待代码没有关联,你们应该都没拉下来试就来回帖了吧
jessicway 2010-01-18
  • 打赏
  • 举报
回复
jsp文件全部贴上来吧,否则没法看
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
The type List is ambiguous

List 类型不清楚
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
Unable to compile class for JSP:

1.
原因是编译器不没jre或者不对。
2.
tomcat 中 指定jre
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
报错信息是什么?
coveking 2010-01-18
  • 打赏
  • 举报
回复
沙发抢下来,报错的代码是:

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

An error occurred at line: 328 in the jsp file: /pages/month/cardChannel.jsp
The type List is ambiguous
325: String verify_rlt = element.getChild("Verify_rlt").getText();
326: String photo = element.getChild("Photo").getText();
327: String photot = element.getChild("Photot").getText();
328: List photos = element.getChildren("Photos");
329: for(int i = 0; i< Integer.valueOf(photot).intValue(); i++){
330: Element photoString=(Element)photos.get(i);
331: String pStr = photoString.getText();


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

328行是什么原因导致的???
coveking 2010-01-18
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 zhangzhenting 的回复:]
An error occurred at line: 328 in the jsp file: /pages/month/cardChannel.jsp

The type List is ambiguous

好像在你贴出来的JSP页面里面都没有 List 的哦
[/Quote]

我就是不想大家混淆了我代码,所以单独调用出来这个方法做测试test.jsp页面
zhangzhenting 2010-01-18
  • 打赏
  • 举报
回复
An error occurred at line: 328 in the jsp file: /pages/month/cardChannel.jsp

The type List is ambiguous

好像在你贴出来的JSP页面里面都没有 List 的哦
zhangzhenting 2010-01-18
  • 打赏
  • 举报
回复
晕了 /pages/month/cardChannel.jsp
是你贴出来的那个JSP页面吗
zhangzhenting 2010-01-18
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 focusforce 的回复:]
用java.util.List photos = element.getChildren("Photos"); 试试吧。

[/Quote]

上面说的对啊, 很明显 错误提示 就是List没有导入的嘛;

或是直接在最上面导入也行:
<%@page import="java.util.List"%>
coveking 2010-01-18
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 nihaozhangchao 的回复:]
引用 8 楼 coveking 的回复:
很无语啊。


我说哥们你的代码是在jsp 在运行的吗?
看这个 <%@page import="java.awt.*"%>
<%@page import="java.awt.image.*"%>
<%@page import="com.sun.image.codec.jpeg.*"%>
<%@page import="javax.imageio.*" %>
应该是在jsp吧。
可是下面的方法也应该加上 <%!
%>吧。
[/Quote]


<%@page import="java.awt.*"%>
<%@page import="java.io.*"%>
<%@page import="java.awt.image.*"%>
<%@page import="com.sun.image.codec.jpeg.*"%>
<%@page import="javax.imageio.*" %>
<%@page import="java.awt.*"%>
<%@page import="java.util.*"%>
<%!
public static void addPhotoFrame (String framPicName, String srcPicName, String outputPicName) throws Exception {
//相框文件
File framePicFile = new File(framPicName);
Image framePic = ImageIO.read(framePicFile);
int width = framePic.getWidth(null);
int height = framePic.getHeight(null);
BufferedImage image=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
g.drawImage(framePic, 0, 0, width, height, null);
//原图片文件
File srcPicFile = new File(srcPicName);
Image srcPic = ImageIO.read(srcPicFile);
int srcWidth = srcPic.getWidth(null);
int srcHeight = srcPic.getHeight(null);
g.drawImage(srcPic, 0, 6, srcWidth, srcHeight, null);
g.dispose();
FileOutputStream out = new FileOutputStream(outputPicName);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(image);
out.close();
}
%>
<%
addPhotoFrame("2.jpg","1.jpg","3.jpg");
%>


都有加的,代码就是这样,运行下报的错
SambaGao 2010-01-18
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 coveking 的回复:]
很无语啊。
[/Quote]

我说哥们你的代码是在jsp 在运行的吗?
看这个<%@page import="java.awt.*"%>
<%@page import="java.awt.image.*"%>
<%@page import="com.sun.image.codec.jpeg.*"%>
<%@page import="javax.imageio.*" %>
应该是在jsp吧。
可是下面的方法也应该加上<%!
%>吧。
focusforce 2010-01-18
  • 打赏
  • 举报
回复
用java.util.List photos = element.getChildren("Photos"); 试试吧。
coveking 2010-01-18
  • 打赏
  • 举报
回复
很无语啊。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧