eclipse、jetty

eclipse配置jetty,启动应用,在浏览器访问。eclipse控制台报oejh.HttpParser:Full;

img

浏览器报413。是啥原因呢?

img

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 以下回答来自chatgpt:

    出现这种情况的可能原因是由于HTTP请求的body过大,超过了服务器的最大限制。需要调整服务器的最大请求大小限制。

    以下是参考代码:

    解决方案

    1. 修改Jetty的配置文件

    找到Jetty的配置文件jetty.xml,一般在jetty.home/etc/jetty.xml路径下,修改<Set name="maxFormContentSize">0</Set>这一行的值,将其设为大于请求body大小的值,单位为字节。例如:

    <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
      <Set name="maxFormContentSize">50000000</Set>
      <!-- 其他配置 -->
    </New>
    

    2. 使用代码配置

    通过代码的方式配置Jetty的最大请求大小限制,需要在Server对象创建完成后,在ServerConnector上设置HttpConnectionFactoryHttpConfiguration对象:

    Server server = new Server();
    ServerConnector connector = new ServerConnector(server);
    
    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setMaxFormContentSize(50000000); // 设置最大请求body大小
    
    HttpConnectionFactory connectionFactory = new HttpConnectionFactory(configuration);
    ServerConnector connector = new ServerConnector(server, connectionFactory);
    
    server.addConnector(connector);
    // 其他配置
    
    server.start();
    

    如果以上两种方法都不能解决问题,可能是由于其他原因引起的,建议查看Jetty或eclipse的官方文档或论坛,或者尝试使用其他服务器或IDE启动应用。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^