eclipse配置jetty,启动应用,在浏览器访问。eclipse控制台报oejh.HttpParser:Full;
浏览器报413。是啥原因呢?
eclipse配置jetty,启动应用,在浏览器访问。eclipse控制台报oejh.HttpParser:Full;
浏览器报413。是啥原因呢?
出现这种情况的可能原因是由于HTTP请求的body过大,超过了服务器的最大限制。需要调整服务器的最大请求大小限制。
以下是参考代码:
找到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>
通过代码的方式配置Jetty的最大请求大小限制,需要在Server
对象创建完成后,在ServerConnector
上设置HttpConnectionFactory
的HttpConfiguration
对象:
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启动应用。