Spring Rest API最大大小HTTP POST

我目前有一个Java Spring Rest API,可以将图像base64上传到我的服务器。 现在我想知道是否有一种方法可以限制上传大小,以便人们无法上传1GB并使我的服务器崩溃。

是否有用于Polyline简化的开源Java库?

主要是Douglas-Peucker算法的实现。

获取整个文档innerhtml

有没有办法获得整个页面的innerhtml,包括html,head,body等。 我只能调用page.getDocument().getBody().getInnerHTML() …没有page.getDocument().getInnerHTML() …应该没有?

如何以multithreading方式调用不同类的相同方法

我在我的两个类中有一个名为process的方法,比如说CLASS-A and CLASS-B 。 现在在下面的循环中,我调用我的两个类的process method顺序意义一个接一个,它工作正常,但这不是我想要的方式。 for (ModuleRegistration.ModulesHolderEntry entry : ModuleRegistration.getInstance()) { final Map response = entry.getPlugin().process(outputs); // write to database System.out.println(response); } 有什么办法,我可以用multithreading方式调用我的两个类的进程方法。 这意味着一个线程将调用CLASS-A的进程方法,第二个线程将调用CLASS-B的进程方法。 之后我想将process方法返回的数据写入数据库。 所以我可以再写一个线程来写入数据库。 下面是我以multithreading方式提出的代码,但不知何故它根本没有运行。 public void writeEvents(final Map data) { // Three threads: one thread for the database writer, two threads for the plugin processors final ExecutorService executor = Executors.newFixedThreadPool(3); final […]

Java通用枚举function使用java 8默认方法和实用程序类

下面是我提出的失败尝试,指的是使用Reflection的Java Generic Enum类 。 想找到一个更好的方法来做到这一点。 我用这种方法找到了几个问题: 每次我都需要传递类类型。 示例 – EnumUtility.fromKey(Country.class,1) fromSet在城市和国家都重复 public enum City implements BaseEnumInterface { TOKYO(0), NEWYORK(1); private final int key; public static Set fromValue(Set enums) { return enums.stream().map(City::getKey).collect(Collectors.toSet()); } public int getKey() { return key; } private City(int key) { this.key = key; } } public enum Country implements BaseEnumInterface { USA(0), […]

Firebase Admin Java SDK没有执行任何操作

我已使用本指南设置了firebase管理SDK 所以我用以下方式初始化它。 InputStream refreshToken = new ClassPathResource(CONFIG_FILE).getInputStream(); FirebaseOptions options = new FirebaseOptions.Builder() .setCredential(FirebaseCredentials.fromRefreshToken(refreshToken)) .setDatabaseUrl(“https://.firebaseio.com/”) .build(); FirebaseApp.initializeApp(options); 到目前为止我没有错误,一切似乎都很好。 但是,我无法进行任何操作。 调用方法什么都不做。 例如: FirebaseDatabase.getInstance() .getReference() .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { //this callback is never called } @Override public void onCancelled(DatabaseError databaseError) { } }); 要么 class Pojo { public Pojo(String name, String surname) { […]

使用Java和递归的二级树遍历级别顺序遍历

我在使用递归时遇到二叉树的级别顺序遍历问题。 我输入以下值:50,60,70,30,20,10这是我正在使用的代码: public void levelOrder(Node localRoot){ if(localRoot != null){ if(localRoot.leftChild != null && localRoot.rightChild != null){ System.out.print(localRoot.iData + ” “); System.out.print(localRoot.leftChild.iData + ” “); System.out.print(localRoot.rightChild.iData + ” “); levelOrder(localRoot.leftChild); levelOrder(localRoot.rightChild); } else if(localRoot.rightChild == null && localRoot.leftChild == null){ ; } else if(localRoot.rightChild == null){ System.out.print(localRoot.leftChild.iData + ” “); //levelOrder(localRoot.leftChild); } else{ System.out.print(localRoot.rightChild.iData + ” […]

javamail API中的SMTP身份validation问题

import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.mail.event.*; import java.net.*; import java.util.*; public class servletmail extends HttpServlet { public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException { PrintWriter out=response.getWriter(); response.setContentType(“text/html”); try { Properties props=new Properties(); props.put(“mail.transport.protocol”, “smtp”); props.put(“mail.smtp.host”,”smtp.gmail.com”); props.put(“mail.smtp.port”, “25”); props.put(“mail.smtp.auth”, “true”); Authenticator authenticator = new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return […]

NamedJDBCTemplate参数是列表列表

我有一个看起来像这样的查询: SELECT * FROM someTable t WHERE (ta, tb) IN (VALUES (1, 2), (3, 4)) 并且它将选择ta == 1 AND tb == 2或ta == 3 AND tb == 4任何记录。 这似乎工作得很好。 但是,我无法找到一种干净的方法来为NamedJDBCTemplate指定参数。 我尝试给它一个列表列表(即List<List> ),但它似乎炸毁了这样做。 val query = “SELECT * FROM someTable t WHERE (ta, tb) IN (VALUES :values)” namedJdbcTemplate.queryForList(query, mapOf(“values” to listOf(listOf(1, 2), listOf(3, 4)))) 我也尝试手动将值转换为字符串,但这也不会让它变得快乐。 namedJdbcTemplate.queryForList(query, […]

Log4j – 使用DatePattern后文件扩展名(.log)消失

我的Log4j.xml文件有问题。 当我保存这样的日志文件时: 文件没问题,但没有文件扩展名。 这是一个错误还是我做错了什么? 编辑:在我看到保罗的回答之前,我通过使用一个简单的类初始化我的记录器来暂时解决了我的问题。 这不是最好的决定,但它对有类似问题的人有用: public class DomainLogger { private Logger logger = null; public DomainLogger(String directoryName, String fileName) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat(“_dd.MM.yyyy”); String timeNow = sdf.format(new Date()); String fullFilePath = System.getenv(“DOMAIN_HOME”) + directoryName + “\\” + fileName + timeNow + “.log”; System.out.println(“full filepath is ” + fullFilePath); logger = […]