Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Struts 2中动作映射的Spring MVC等价物_Spring_Spring Mvc_Struts2_Action Mapping - Fatal编程技术网

Struts 2中动作映射的Spring MVC等价物

Struts 2中动作映射的Spring MVC等价物,spring,spring-mvc,struts2,action-mapping,Spring,Spring Mvc,Struts2,Action Mapping,SpringMVC是否有与Struts 2相同的/类似的动作映射xml配置 e、 g.在Struts2应用程序中,我有: <action name="index" class="homeAction"> <interceptor-ref name="myAppVarsBasic" /> <interceptor-ref name="defaultStack" />

SpringMVC是否有与Struts 2相同的/类似的动作映射xml配置

e、 g.在Struts2应用程序中,我有:

<action name="index" class="homeAction">
    <interceptor-ref name="myAppVarsBasic" />
    <interceptor-ref name="defaultStack" />
    <result name="input">/WEB-INF/jsp16/home.jsp</result>
    <result name="userDisplay">/WEB-INF/jsp16/userDisplay.jsp</result>
    <result name="changePassword" type="redirectAction" >passwordReset!changePass.do</result>
</action>
SpringMVC是否有与Struts 2相同的/类似的动作映射xml配置

SpringMVC具有基于xml的配置、注释和JavaConfig。它的xml配置文件中有几个名称空间。最有用的是
bean
名称空间。您可以在那里定义bean配置。您可以在bean的
name
属性中定义路径,或者使用
@RequestMapping
注释

当Struts2与Spring集成时,您可以在
struts.xml
中配置动作,并在
applicationContext.xml
中为动作类定义bean。您只需放置bean的id,而不是在action配置中的
class

在SpringMVC中,您可以将请求路径映射到带有
@RequestMapping
注释的方法。类似于Struts1绘制了他们的行动。在SpringMVC4中,它还支持通配符和正则表达式来匹配请求路径

Spring也有拦截器,但它们只是AOP名称空间中的切入点。当然,您可以在Spring配置中使用它们

Struts2中的结果只是初始操作结束时执行的另一个操作。SpringMVC返回一个带有
模型的
视图
对象。它可以返回字符串、另一个对象或什么都不返回。SpringMVC中的结果是实际请求的方法返回的结果。结果由视图解析器处理。SpringMVC有许多视图解析,您可以将其配置为能够处理servlet调度器请求的bean


是否有类似的方法使用xml配置配置SpringMVC来配置操作映射、重定向和到何处

其中之一是与Struts 2操作配置类似的
XmlViewResolver
。你可以在网站上阅读更多关于这些bean的内容。使用此解析器,您可以通过
views.xml
定义视图,将其作为属性馈送到此解析器,并使用映射到每个JSP的视图名称



唯一的问题是为什么?做你更了解的框架。我再也找不到工作了。谢谢你,罗曼。有了这个答案,我现在掌握了下一步的正确位置和术语,非常感谢!灵魂。
return "redirect:index";