이에 컨트롤러와 OPTIONS 요청에있는 하나의 방법에 GET 요청을지도로 :구성 스프링 MVC는 아주 쉽게 사용 주석 것 다른 방법
@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
}
}
하지만 XML에서이 작업을 수행하는 방법을 찾을 수 없습니다. 다음과 같은 작업을 수행 할 매핑 핸들러가 있습니까 :
<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>
모든 포인터가 도움이 될 것입니다.