问题描述
- 关于使用struts2注解和sping整合的问题。
-
如题,struts2与spring整合后,struts2使用注解的方式,struts.xml加入如下配置信息:<constant name="struts.convention.action.suffix" value="Action"/> <constant name="struts.convention.package.locators" value="action"/> <constant name="struts.convention.result.path" value="/WebRoot"/> <constant name="struts.objectFactory" value="spring" />
那么Action类中:
@Component @Scope("prototype") @Namespace("/u") @Results({ @Result(name = "success",location = "/Success.jsp"), @Result(name = "fail",location = "/Fail.jsp"), }) public class UserAction extends ActionSupport implements ModelDriven { ...
发现spring注解加不加都能正常运行。
我想知道,请问有spring注解和没spring注解这两种情况下,action的创建分别是由谁管理创建的呢?
先谢谢大家
解决方案
struts2 注解的使用
struts2:使用拦截器注解
在Struts2框架中使用注解
解决方案二:
Struts起到方法分发器的作用,Spring更倾向于逻辑业务层的管理。
时间: 2024-09-12 13:02:04