Java embedded jetty server

Sometimes a simple function needs to be encapsulated as a service. Compared with Python, flash and web Py is simple, and using java web is too heavyweight. Fortunately, we can directly use jetty in Java projects to build simple services

1、pom. Adding jetty dependency to XML

2. Add server

3. Set servletcontexthandler

4. Add servlet 4.1 to context, create a servlet, inherit httpservlet, and overload doget and dopost

4.2 add servlet to context

5. Start server

6. Access in browser http://localhost:12580/XXX Just

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>