Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我看到很多关于如何通过 xml 配置进行操作的信息,但我使用的是嵌入式 Tomcat,并希望以编程方式设置它。
您可以通过几乎相同的方式以编程方式和使用 XML 来参数化 Tomcat。
例如,maxThreadsXML 中用于限制线程池大小的属性也可以通过以下方式设置:
maxThreads
Tomcat tomcat = new Tomcat(); Connector connector = tomcat.getConnector(); connector.setProperty("maxThreads", "2");
这应该适用于任何 XML 属性。