[英]spring upgradation to Spring 4 with controller mapping
I am upgrading spring 3 to spring 4. Earlier I was using urlmapping in dispatcher-servlet.xml file to hit the controller class. 我将Spring 3升级到Spring4。之前,我在dispatcher-servlet.xml文件中使用urlmapping来访问控制器类。 The URL was invoked directly on controller and method name.
URL直接在控制器和方法名称上调用。 Now when I am migrating it to Spring 4 I have used @RequestMapping in controller class, but not sure how to invoke method directly.
现在,当我将其迁移到Spring 4时,我在控制器类中使用了@RequestMapping,但不确定如何直接调用方法。
dispatcher-servlet.xml -> dispatcher-servlet.xml->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="Test/*.do">TransactionController</prop>
</props>
</property>
</bean>
So if I want to invoke method1 of TransactionController I directly invoke it as: /Test/method1.do 因此,如果我想调用TransactionController的method1,则可以直接将其调用为:/Test/method1.do
Now in Spring 4 I am using @RequestMapping so at class I have put below code: 现在在Spring 4中,我使用@RequestMapping,因此在课堂上,我输入了以下代码:
@Controller
@RequestMapping("/Test/*.do")
Now when I invoke /Test/method1.do then it gives 404 error. 现在,当我调用/Test/method1.do时,它将显示404错误。 Not sure how to do it at class level instead of putting the RequestMapping at method level.
不确定如何在类级别执行此操作,而不是将RequestMapping放在方法级别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.