Understanding contexts in Spring MVC

前端 未结 2 574
情深已故
情深已故 2020-12-03 11:04

I am new to spring and I am creating a simple web application. I have been reading about contexts in Spring MVC.

I am using STS plugin for eclipse. I created a Spri

2条回答
  •  执笔经年
    2020-12-03 11:34

    Well spring does not force you to have xml files in that way, you can very well work everything using only one xml file that would be servlet-context.xml and using only dispatcher servlet. Generally there are different files in order to define your service beans or dao beans, so this basically depends on your application design, for eg if you are using spring security you might want to add one more xml file something like security-context.xml like as I said it depends on design. You can actually eliminate context loader listener completely and still manage to do everything using dispatcher servlet. Your question is too broad in scope, since you are new to spring may be you should get more details about spring containers and decide what suits your requirement. I generally have my servlet-context.xml in WEB-INF and other configuration like service-context.xml in classpath, again this is no strict rule just how it suits me.

提交回复
热议问题