是否可以僅使用dispatcher-servlet.xml
來運行spring-orm程序。沒有使用ContextLoaderListener
和applicationcontext.xml
?如果是,那麼如何?我的spring程序能否使用dispatcher-servlet.xml運行而不使用ContextLoaderListener和applicationcontext.xml?
其次爲什麼有必要註冊dispatcher-servlet.xml
或applicationcontext.xml
在web.xml
?因爲當這些文件未在web.xml
中註冊時,所有設置程序注入(在dispatcher-servlet.xml
或applicationcontext.xml
中指定)都會在服務器啓動時發生,這意味着這些xml文件正在加載而不在web.xml
中進行註冊。
dispatcher-servlet.xml爲您的調度程序servlet配置上下文。我認爲你需要閱讀更多關於Spring的知識 - xml文件不是在web.xml中「註冊」的,它們是Spring的上下文加載器的參數。如果不想創建上下文,你想如何使用dispatcher-servlet.xml? – Paul