尝试使用JSP / Servles使用JFreeChart; JDBCCategoryDataset和CategoryDataset的问题

我正在尝试连接到数据库并在servlet中执行查询。 我正在按照这个例子JFreeChart示例 。 如果查看readData()方法,它会在最初为JDBCCategoryDataset时返回CategoryDataset 。 我得到一个错误,直到我把它做了一个CategoryDataset 。 当我运行代码时,它不起作用,告诉我它无法投射。 任何帮助将非常感激!

如何使用java util logging框架以特定格式为每条记录创建日志文件

我想使用java util logging以下面的格式为每个请求创建日志文件。 YYYYMMDD_HHMMSS.log 有人请让我知道如何使用java util logging实现这一目标?

使用java邮件api发送邮件时发生MailConnectException

尝试使用java mail api发送电子邮件。 而且我一直收到MailConnectException。 我尝试了多种方法来解决它而没有成功。 此声明抛出exception transport.connect(“smtp.gmail.com”, “someone@gmail.com”, “myPassword”); 谁能告诉我我做错了什么? public static void main(String[] args) { String host = “smtp.gmail.com”; String from = “someone@gmail.com”; Properties props = System.getProperties(); props.put(“mail.smtp.host”, host); props.put(“mail.smtp.user”, from); props.put(“mail.smtp.password”, “myPassword”); props.put(“mail.smtp.port”, “465”); props.put(“mail.smtp.auth”, “true”); try{ Session session = Session.getDefaultInstance(props, null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipients(Message.RecipientType.TO, “someone@hotmail.com”); message.setSubject(“sending in […]

通过按钮单击循环浏览Jlabel的图像时出现循环问题

在java应用程序中我有一个Jlabel,我想在每次单击一个按钮时分配一个新图像,使用for循环我可以让它只显示跳过图像之间的所有最后一个图像,我知道有一个错误在我的逻辑中,也许我不应该使用for循环? 任何建议 private String imageList[]; ImageIcon image; imageList = new String[] {“src\\Tour_Eiffel_Wikimedia_Commons.jpg”,”src\\Ben.jpg”, “src\\Rio.jpg”, “src\\Liberty.jpg”, “src\\Pyramid.jpg”}; //constructor setting first image to display on load public GeographyGameGUI() { image = new ImageIcon(imageList[0]); imageLbl.setIcon(image); } //button method private void nextBtnActionPerformed(java.awt.event.ActionEvent evt) { for (imgCount = 1; imgCount < imageList.length; imgCount++) { image = new ImageIcon(imageList[imgCount]); imageLbl.setIcon(image); } 如果我不使用for循环并简单地使用我在按钮方法之外声明的计数器(如下所示),它会正确地循环显示图像但会遇到ArrayIndexOutOfBoundsException。 […]

带有FormDataContentDisposition的org.glassfish.jersey上传文件

http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/我正在按照本指南操作并遇到问题。 我有一些疑问。 所有的依赖都必须对应吗? 我的项目有一些org.glassfish.jersey依赖项,本指南建议使用org.sun.jersey。 我是否必须使用与此相同的版本进行更改? org.glassfish.jersey.media jersey-media-multipart 2.16 org.glassfish.jersey.core jersey-server 2.16 我有这个错误 org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization. [[FATAL] No injection source found for a parameter of type public ***.***.****.common.dto.response.AbstractResponse ***.***.****.m2m.instancetypeupload.webservice.InstanceTypeUploadWebService.upload(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition) at index 0.; source=’ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/json], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class ***.***.****.m2m.instancetypeupload.webservice.InstanceTypeUploadWebService, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@90516e]}, definitionMethod=public ***.***.***.common.dto.response.AbstractResponse ***.***.*****.m2m.instancetypeupload.webservice.InstanceTypeUploadWebService.upload(java.io.InputStream,org.glassfish.jersey.media.multipart.FormDataContentDisposition), parameters=[Parameter [type=class java.io.InputStream, […]

替换PDF中的签名内容

如何在iText中完成? 我有一张带有客户签名的PDF。 我需要为无符号属性添加ocsp响应。 我知道如何使用改变签名本身 org.bouncycastle.cms.CMSSignedData.replaceSigners(…).getEncoded() 但我不知道如何使用new PdfString(newSignature).setHexWriting(true)替换PDF中的new PdfString(newSignature).setHexWriting(true) 。 如果我使用此代码: PdfDictionary other = new PdfDictionary(); other.put(PdfName.CONTENTS, new PdfString(newSignature).setHexWriting(true)); dicSignature.merge(other); 其中dicSignature是包含签名的字典,然后签名(在Adobe Reader中打开文档时)被破坏。

如何使用Java和SAX解析我的简单XML文件?

我试图解析下面的文件。 我想打印每位乘客的身份和姓名。 你能给我解析它的代码吗? Tom Cruise Tom Hanks 更新这是我尝试过的。 这里提到的代码,问题等 – 简单SAX解析器的输出出错

轻松创建“加载”动画

我有一个android listView ,每个项目都有一个图像。 图像加载需要一段时间。 如何在每次加载图像时添加“加载”动画? 我应该使用.gif吗? 或者创建我自己的动画并在onPostExecute()上停止它? 如果我使用“picasso”,我怎么能这样做,因为所有异步任务都是开发人员的黑盒子,我不能停止任何动画?

如何将标签值和误差线添加到JFreeChart折线图?

我正在使用JFreeChart创建折线图,这些折线图作为图像导出并嵌入到自动生成的文档中。 例如,一个简单的折线图如下所示: 我用来显示值的代码是: LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false); chart.getCategoryPlot().setRenderer(renderer); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(“{2}”, NumberFormat.getNumberInstance())); renderer.setBaseItemLabelsVisible(true); 我还想添加错误条来显示每个点的标准偏差,这可以通过使用StatisticalLineAndShapeRenderer(当然还有错误值添加到数据集)来完成,这样上面的chode现在变为: StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false); chart.getCategoryPlot().setRenderer(renderer); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(“{2}”, NumberFormat.getNumberInstance())); renderer.setBaseItemLabelsVisible(true); 使用此代码,图表将生成错误栏,但标签已消失。 从图中可以看出: 我试图找到一个包含错误栏和标签的在线示例,但我没有这样做。 使用Statustical Renderer时为什么标签会消失,有什么方法吗? 编辑:添加了最小和自包含的示例。 DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1, 0.1, “serie”, “A”); dataset.add(2, 0.4, “serie”, “B”); dataset.add(2, 0.2, “serie”, “C”); JFreeChart chart = ChartFactory.createLineChart(“Chart”, null, null, […]

从计算机中读取文件

现在我有这个错误: 线程“main”中的exceptionjava.lang.ArrayIndexOutOfBoundsException:4在Lotto1.main(Lotto1.java:37) 第37行:arr [count] [0] = s.next()+“”+ s.next(); import java.io.*; import java.util.*; public static void main(String[] args) throws IOException { File f = new File(“D:\\Filipe\\Project Final\\src\\database_lotto.txt”); Scanner s; try { s = new Scanner(f); BufferedReader reader = new BufferedReader(new FileReader(f)); int lines = 0; while (reader.readLine() != null) { lines++; } reader.close(); arr = new […]