The difference between web.xml, beans.xml, applicationContext.xml, etc

后端 未结 1 875
深忆病人
深忆病人 2020-12-23 14:58

I\'ve been working with Spring MVC for a while now creating my projects in Netbeans running on Glassfish servers. While everything is working fine I feel like I lack underst

相关标签:
1条回答
  • 2020-12-23 15:27

    web.xml is a file that should reside in all J2EE web application. Its specification is defined by J2EE spec. Here you configure a general behaviour of your app. For example servlets, filters, security policy etc.

    dispatcher-servlet is a special servlet in Spring MVC framework. You must define its mapping in your web.xml to enable Spring in your web app.

    beans.xml is a file that is use for configure some CDI settings. For example bean-discovery-mode="annotated" means that only classes annoteded with CDI scope annotation will be consider as CDI managed beans.

    applicationContext.xml here you are actually right. It is the common name of the main Spring configuration file. You can set many things here like for example create and wire some Spring beans.

    glassfish-web.xml is generally an extension to web.xml for GlassFish server. It is not always needed. You need it if want to configure some settings specially for GlassFish server. For example if you configure the security part in your web.xml you have to map user roles from web.xml to GlassFish realm roles.

    Hope it helps.

    0 讨论(0)
提交回复
热议问题