Sample Spring-Dispatcher-Servlet file example

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
   xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-4.2.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
   
  <!-- default HandlerMapping -->
  <!-- <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> -->
  <!-- Controller Mapping --> 
  <!-- <bean name="/hello.html" class="com.shivlab.test.controller.HelloController"/>  -->
  
   <!-- Controller class scan package name -->
   <context:component-scan base-package="com.shivlab" /> 
   
   <!-- Static resource mapping -->
   <mvc:annotation-driven />
   <mvc:resources mapping="/assets/**" location="/assets/" />
 
   
   <!-- SimpleUrlHandlerMapping  
   <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
   <property name="mappings">
    <props>
     <prop key="/hello.html">hc</prop>
    </props>
   </property>
  </bean> 
 <bean id="hc" class="com.shivlab.test.controller.HelloController"/>  -->
 
 <!-- ControllerClassNameHandlerMapping
   <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
   <bean class="com.shivlab.test.controller.HelloController"></bean>
    -->
   <!-- ViewResolver Mapping -->
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix" value="/jsp/" />
  <property name="suffix" value=".jsp" />
 </bean>
 
   </beans>

Comments

Popular posts from this blog

How to Install AnyDesk remote desktop client on Ubuntu

How to install Jaspersoft Studio on Eclipse

What is Advanced Encryption Standard (AEC) and online tool to encrypt and decrypt data using AEC.