Giriş
Servlet olarak org.springframework.web.servlet.DispatcherServlet belirtilir
Örnek
Şöyle yaparız
servlet-name olarak ne verdiysek isim + "-servlet.xml" diye bir dosya oluşturulur. Dosyada Spring bean'leri tanımlanır. Bu örnek için xml dosyası şöyledir<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
spring-servlet.xml
<beans ...>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- max upload size in bytes -->
<property name="maxUploadSize" value="2097152" /> <!-- 2MB -->
<!-- max size of file in memory (in bytes) -->
<property name="maxInMemorySize" value="10240" /> <!-- 10 kB -->
</bean>
<context:component-scan base-package="com.nsn.advantage.in.railway.gui.controller" />
<context:component-scan base-package="com.nsn.advantage.in.railway.gui.batchprocess" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<bean id="myHttpController" class="com.foo.MyHttpController" >
<property name="jndiBean" ref="jndiBean" />
</bean>
<bean id="jndiBean" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"
value="#{T(com.foo.MyBeansUtils).SESSION_BEAN_LOCAL_JNDI}" />
</bean>
<bean id="urlMapAdmin"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<props>
<prop key="/myHttp">myHttpController</prop>
</props>
</property>
</bean>
</beans>
Hiç yorum yok:
Yorum Gönder