This would be pretty easy using annotations:
@Controller
public class MyController {
@RequestMapping(value="/hitmycontroller", method= RequestMethod.OPTIONS)
public static void options(HttpServletRequest req,HttpServletResponse resp){
//Do options
}
@RequestMapping(value="/hitmycontroller", method= RequestMethod.GET)
public static void get(HttpServletRequest req,HttpServletResponse resp){
//Do get
}
}
but I can't find how to do this in XML. Is there some mapping handler that will do something like this:
<bean id="handlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<mapping>
<url>/hitmycontroller</url>
<httpMethod>GET</httpMethod>
<method>get</method>
<controller>MyController</controller>
</mapping>
<mapping>
<url>/hitmycontroller</url>
<httpMethod>OPTIONS</httpMethod>
<method>options</method>
<controller>MyController</controller>
</mapping>
</property>
</bean>
Any pointers would be appreciated.