Java数独生成器无法正常工作

我一直在研究java中的数独谜题生成器,我写了这个类来生成谜题,但它没有正确生成谜题。 这是我得到的一个例子: 如您所见,这不是一个有效的数独解决方案。 但是看看我的代码,我不明白它为什么没有产生有效的谜题。 有人可以解释为什么这不能正常工作? package sudoku; import java.util.Random; public class Puzzle { // number generator Random gen = new Random(); // 9×9 puzzle int puzzle[][] = new int[9][9]; public int[][] generate() { // add each number to the board for (int x = 0; x < 9; x++) { for (int y = 0; […]

如何在不使用任何操作类的情况下使用Struts2约定

在Struts2中,我们可以在不使用struts.xml动作类的情况下定义动作,如下所示: /error.jsp 在我的应用程序中,我使用struts2 convention 。 在这种情况下如何避免编写动作类。 我有很多场景,我只想在不使用任何业务逻辑的情况下访问该页面。 我的结果路径不仅仅是一个JSP。 我正在使用瓷砖。 我使用的代码如下: @Action(value=”homePage”, results={@Result(name=”success”, location=”homePage”, type=”tiles”)})

javax.mail.MessagingException:

package com.mca2b; import java.util.Properties; import javax.mail.util.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SampleMail { public static void main(String [] args) throws Exception{ String to = “kalgaonkarsiddhesh@gmail.com”;//change accordingly String from = “siddhesh.kalgaonkar@ves.ac.in”;//change accordingly String host = “localhost”;//or IP address // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.setProperty(“mail.smtp.host”, host); // […]

java.io.IOException已建立的连接已被主机中的软件中止

当我对远程服务器进行一次servlet调用时,我经常收到此错误。 运行java application1,用少量数据调用servlet调用application2。 应用程序2必须返回一些数据。 但经常我在application2中得到低于错误,而返回响应为ObjectOutputStream,有时它工作正常。 我正在使用tomcat 8。 org.apache.catalina.connector.ClientAbortException: java.io.IOException: An established connection was aborted by the software in your host machine 15:45:44:776 PM at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:393) 15:45:44:776 PM at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426) 15:45:44:776 PM at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339) 15:45:44:776 PM at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:418) 15:45:44:776 PM at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:406) 15:45:44:776 PM at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:97) 15:45:44:776 PM at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source) 15:45:44:776 PM at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(Unknown Source) […]

如何在项目中包含多个log4j2.xml文件?

我的项目由多个模块组成。 每个模块都可以独立运行,并具有单独的log4j2.xml 说项目X由三个模块组成: 模块A有log4j2.xml(包含Loggers和Appenders) 模块B有log4j2.xml 模块C有log4j2.xml 在集成模块时,我必须手动将Loggers和Appender从每个模块的log4j2.xml复制粘贴到项目特定的log4j2.xml文件中。 为了避免复制粘贴,我一直在寻找包含多个文件的XInclude ,但它只支持Appenders和Logger在不同的文件中。 http://logging.apache.org/log4j/2.x/manual/configuration.html#XInclude 如何XInclude多个log4j2.xml文件? 任何帮助是极大的赞赏。

从Java写入XML文档 – 简单

我知道在stackoverflow上从Java写到XML有很多问题,但它太复杂了。 我觉得我有一个非常简单的问题,我无法弄清楚。 所以我有一个程序需要大量的用户输入,我现在正在创建并附加带有结果的文本文档。 我将在这里发布我的编写器代码: PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter(“C:/Documents and Settings/blank/My Documents/test/test.txt”, true))); out.println(“”); out.println(“<event title=\""+titleFieldUI+"\""); out.println(" start=\""+monthLongUI+" "+dayLongUI+" "+yearLongUI+" 00:00:00 EST"+"\""); out.println(" isDuration=\"true\""); out.println(" color=\""+sValue+"\""); out.println(" end=\""+monthLong1UI+" "+dayLong1UI+" "+yearLong1UI+" 00:00:00 EST"+"\""); out.println(" "+descriptionUI); out.println(""); out.println("”); out.println(” “); }catch (IOException e) { System.err.println(e); }finally{ if(out != null){ out.close(); […]

如何在QNX6下提高Eclipse IDE的性能

我们在VMWare环境中通过QNX6运行Eclipse,速度非常慢。 Eclipse的启动方式如下: /usr/qnx630/host/qnx6/x86/usr/qde/eclipse/eclipse -data /root//workspace /usr/qnx630/host/qnx6/x86/usr/qde/eclipse/jre/bin/pvm -pri 13 -ts 4 -gs 4 -gcperiod 500 -cs 512000 -nojit -numregs 64 -maxmem 256M -Djava.version -classpath /usr/qnx630/host/qnx6/x86/usr/qde/eclipse/startup.jar org.eclipse.core.launcher.Main -os qnx -ws photon -arch x86 -showsplash /usr/qnx630/host/qnx6/x86/usr/qde/eclipse/eclipse -showsplash 600 -exitdata /usr/qnx630/host/qnx6/x86/usr/qde/eclipse/eclipse -exitdata /tmp/eclipse_25b034 -data /root//workspace 有什么想法让它更快? 就像关闭一些function,调整gc一样,一般的想法不是QNX或VMWare特有的……

限制REST API的JSON响应中的字段?

我正在使用Spring和Java并实现基于REST的服务。 我有一组为移动,iPad和Web开发的开发人员。 考虑我有一个豆子 Class User{ private String Name; private Integer id; private String photoURL; private ArrayList ProjectName; private ArrayList TechnologyList; private ArrayList InterestList; //Getters and setters } 虽然Web开发人员需要整个领域,而移动开发人员只需要两个字段,而iPad需要移动和网络之间的东西。 由于我使用jackson作为解析器,有没有办法在请求控制器时我可以指定我需要的所有数据并避免其他数据。 例如,考虑我做一个GET请求 GET>http://somedomain.com/users?filter=name,id,photoUrl 这给我带来了类似的JSON结构 { “name”:”My Name”, “id”:32434, “photoUrl”:”/sss/photo.jpg” } Sameway如果有人要求更多字段,可以过滤它们。 请让我知道如何做到这一点,以便我的API保持通用和可用于所有人。

弹簧mvc控制器的unit testing,整数值为@RequestParam

我有以下控制器接受输入为@RequestParam @RequestMapping(value = “/fetchstatus”, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public Response fetchStatus( @RequestParam(value = “userId”, required = true) Integer userId) { Response response = new Response(); try { response.setResponse(service.fetchStatus(userId)); response = (Response) Util.getResponse( response, ResponseCode.SUCCESS, FETCH_STATUS_SUCCESS, Message.SUCCESS); } catch (NullValueException e) { e.printStackTrace(); response = (Response) Util.getResponse( response, ResponseCode.FAILED, e.getMessage(), Message.ERROR); } catch (Exception […]

android cts执行在中途exception停止

Android CTS执行exception中途停止。 有谁知道如何修理它? 版本: Android OS 6.0.1(64位)+ Android CTS 6.0_r6 命令: run cts –plan CTS –shards 3 –skip-preconditions 错误日志: 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba5551_depth_stencil_render PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_no_depth_no_stencil_clear PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_no_depth_no_stencil_render PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_no_depth_stencil_clear PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_no_depth_stencil_render PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_depth_no_stencil_clear PASS 06-16 03:05:20 I/82abb56f: dEQP-EGL.functional.native_coord_mapping.native_pixmap#rgba8888_depth_no_stencil_render PASS 06-16 […]