是否可以在運行時動態添加URL模式到Servlet?例如,當Servlet啓動時,掃描文件夾中的註釋,然後將這些url模式注入到servlet中?Java - 向Servlet動態添加URL模式
- 提供更清晰 -
在Servlet的init文件,我想這樣做(僞代碼)
// scan all the files in the package my.project.services
// find all the classes with the Annotation @Service
// read those annotations, find the url patterns in them, and insert them into the servlet
也許我誤解了。你想在啓動時或之後使用嗎? –
啓動時確定。例如,在servlet的init()函數中。 – bluedevil2k
目的是什麼?你確定使用簡單的控制器模式不會更好嗎? –