zoukankan      html  css  js  c++  java
  • 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());
    }
    %>

  • 相关阅读:
    GitLab 远程 定时备份
    GitLab 本地 定时备份
    MATLAB格式化输出控制
    hilbert矩阵
    MATLAB符号运算
    双线性插值 分类: 图像处理 2015-07-28 15:14 7人阅读 评论(0) 收藏
    shamir叠像术 分类: 图像处理 2015-07-08 16:50 17人阅读 评论(1) 收藏
    cookies、sessionStorage和localStorage解释及区别
    微信小程序,组件之间带参数跳转+轮播图+冒泡事件+表单提交
    微信小程序,头部和底部设置需要注意的事项
  • 原文地址:https://www.cnblogs.com/daxiong225/p/7550917.html
Copyright © 2011-2022 走看看