Как мы можем программно реализовать tomcat в основной функции без XML-файла? Хороший ли подход к программной настройке T ⇐ Apache
-
Anonymous
Как мы можем программно реализовать tomcat в основной функции без XML-файла? Хороший ли подход к программной настройке T
In Below code I add servlet and mapping it in routes class.
public static void main( String[] args ) throws LifecycleException { Tomcat tom = new Tomcat(); tom.setPort(8070); Context context = tom.addContext("/get", null); Tomcat.addServlet(context, "default", new org.apache.catalina.servlets.DefaultServlet()); context.addServletMappingDecoded("/", "default"); Tomcat.addServlet(context, "helloServlet", new Resource()); context.addServletMappingDecoded("/hello", "helloServlet"); tom.start(); tom.getServer().await(); } WHY THIS IS NOT RUNNING TOMCAT AT 8070 PORT , WHEN I CONFIGURE USING XML it working but not with this programmatical approach.
How to run tomcat with programmatic approach and is it good to use or we should always use xml?
Источник: https://stackoverflow.com/questions/781 ... t-xml-file
In Below code I add servlet and mapping it in routes class.
public static void main( String[] args ) throws LifecycleException { Tomcat tom = new Tomcat(); tom.setPort(8070); Context context = tom.addContext("/get", null); Tomcat.addServlet(context, "default", new org.apache.catalina.servlets.DefaultServlet()); context.addServletMappingDecoded("/", "default"); Tomcat.addServlet(context, "helloServlet", new Resource()); context.addServletMappingDecoded("/hello", "helloServlet"); tom.start(); tom.getServer().await(); } WHY THIS IS NOT RUNNING TOMCAT AT 8070 PORT , WHEN I CONFIGURE USING XML it working but not with this programmatical approach.
How to run tomcat with programmatic approach and is it good to use or we should always use xml?
Источник: https://stackoverflow.com/questions/781 ... t-xml-file
Мобильная версия