使用来自字节数组的jetty Web服务器显示图像

我在一个字节数组中有一个图像的内容,在一个jetty servlet类中。 如何在浏览器中显示此图像?

使用@Configuration和@Controller注释一个类。 需要帮助重构

下面是我必须同时使用@Configuration和@Controller类,因为在整个应用程序中应该只有一个Thymeleaf实例,否则我会得到例外。 我的其他类用@RequestScope注释,所以我不能使用单例作用域bean。 所以我有一个配置和控制器的混合来获得结果,但我觉得这是一个不好的做法。 我将不胜感激任何帮助重构代码并删除不良做法。 UPDATE 我使用的是spring-boot 1.5.14 。 我使用以下方法处理模板并将处理后的模板保持为字符串。 @Controller @Configuration @EnableWebMvc @ApplicationScope public class MyThymeleafConfig { @GetMapping(“/view-template”) @ResponseBody public void viewTemplates() { Context context = new Context(); context.setVariable(“mydata”, “this is it”); String html = templateEngine().process(“templates/view-to-process.html”, context); System.out.println(html); } /* configuration for thymeleaf and template processing */ @Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine templateEngine = […]

从java中读取windows和linux中的文件

我有一个位于D:\XML\RequestXML xml文件,我正在从FileReader读取此文件夹中的xml文件。 在我的程序中,我硬编码了文件路径/XML/RequestXML/ 。 这适用于windows环境。 在Windows中, JBoss位于D:\jbossdistrib\jboss 。 我在linux /usr/XML/RequestXML/创建了文件夹结构。 并将xml添加到RequestXML文件夹中。 JBoss位于/usr/jbossdistrib/jboss/ path中。 但我的应用程序找不到在linux环境中的/ XML / RequestXML /中指定的文件。 如果我将文件路径更改为/usr/XML/RequestXML/它在linux中工作。 如何在linux和windows中使用一致的文件路径? public class Controller extends HttpServlet { private String filePath = “/XML/RequestXML/”; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String file = request.getParameter(“fileName”); xml = readFile(filePath + file); } private String readFile(String file) […]

java中的AudioClip和Clip有什么区别?

在我的游戏中,我正在尝试添加sfx和其他声音元素。 我使用AudioClip处理所有事情(BGM,sfx等)。 现在我需要检查sfx是否已经在循环中。 我想知道如果角色靠近门户,则应该循环播放sfx。 如果它超出距离就应该停止。 我读到有一个.isRunning()函数,但就我看来它只能用于Clip。 这是我的代码的一部分。 那么AudioClip和Clip有什么区别? if (hero.getHeroX() > (MAZECOL – 5) * 30 && hero.getHeroY() > (MAZEROW – 4) * 30) if (portalSFX is not in loop) portalSFX.loop(); else portalSFX.stop();

如何在Spring XML文件中使用DOCTYPE

大多数时候我们都没有在Spring中声明DOCTYPE 。 但我想在我的XML上下文文件中声明一个DOCTYPE,以便我可以在我的xml文件中使用ENTITY 。 例如: <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" [ %crmHome;] > 这给出了很多错误,比如… – Attribute “xmlns” must be declared for element type “beans”. – Attribute “xmlns:xsi” must be declared for element type “beans”. etc….. 实现这个目标的方法是什么?

Java方法返回文件数据,输入流或字节数组,哪个更好?

我需要加载许多文件路径小于1MB的二进制文件,如下所示:loadFile(String path); 它应该返回byte []还是Inputstream? 我认为返回byte []将占用大量内存,我不知道如何返回ByteArrayInputStream或事件FileInputream,因为我不知道何时关闭InputStream。 谢谢。

如何在获取“无法解决放置符号”错误时向Hashmap添加键和值

我正在使用Android Studio 1.4.1,我刚刚创建了一个Hashmap,并且正在关注如何填充和操作它的教程(在java上)。 但是我得到一个’无法解决符号放置’错误,而“put”命令为红色。 我添加的图像显示了自动完成快照,虽然导入了java.util.HashMap,但自动完成中没有“put”命令。 可用命令也以红色显示。 我尝试使用它们而不是“put”命令。 我一直有这种类型的问题。 有人可以帮忙吗? 先感谢您… import java.util.HashMap; HashMap pozisyon = new HashMap(); pozisyon.put(“SKale”, “a8”);

如何在Spring Boot中实现Oracle AQ队列?

我已经了解了如何使用AQ(Streams?)包创建Oracle数据库。 我还在Oracle中创建了一些队列(手动)。 (使用PL / SQL和SQL)。 但是,我很难从Spring建立正确的连接。 以下工作(使用oracle.AQ java包): private final String aqUrl = “jdbc:oracle:thin:@localhost:1521:orcl”; private final String aqUser = “queue_mut”; private final String aqPassword = “******”; private final String aqSchema = “queue_mut”; private final String aqTable = “aq_table1”; private final String aqQueue = “aq_queue1”; @Test public void testManualAQ() throws ClassNotFoundException, SQLException, AQException { Class.forName(“oracle.jdbc.driver.OracleDriver”); Connection […]

无法从java.lang.Integer转换为R.

我有以下代码: class inner { Integer i; public Integer getValue() { return i; } public void setValue(Integer i) { this.i = i; } } class outer { public static inner i1; outer(Integer i) { i1.setValue(i); } } public class MyClass{ public void main() { List ll = Arrays.asList(new outer(2)).stream().map(outer.i1::getValue).collect(Collectors.toList()); } 我收到以下错误: required: Function found: outer.i1::getValue reason: […]

用于Windows 7的Gdal(x32)

我如何连接到gdal eclipse。 我尝试了所有不起作用的方式。 我如何连接到gdal eclipse。 我尝试了所有不起作用的方式。 始终发出java.lang.UnsatisfiedLinkError:D:\ Document \ JAVA \ Gdal \ gdalLibrary \ gdaljni.dll:无法找到依赖库