struts和spring整合-关于使用struts2注解和sping整合的问题。

问题描述

关于使用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

struts和spring整合-关于使用struts2注解和sping整合的问题。的相关文章

spring 3.2.x + struts2 + mybatis 3.x + logback 整合配置

与前面的一篇mybatis 3.2.7 与 spring mvc 3.x.logback整合 相比,只是web层的MVC前端框架,从spring mvc转换成struts 2.x系列,变化并不大 一.pom.xml 配置 1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&

namespace-在ssh整合时,使用struts2注解时发生以下错误

问题描述 在ssh整合时,使用struts2注解时发生以下错误 2015-7-14 20:22:47 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn警告: Could not find action or resultThere is no Action mapped for namespace / and action name customerAction. - [unknown location] at com

Struts2和hibernate框架整合实现简单的注册登陆功能

Struts2和hibernate框架整合实现简单的注册登陆功能 项目结构: LoginAction.java package action; import vo.User; import vo.UserDAO; import com.opensymphony.xwork2.ActionSupport; public class LoginAction extends ActionSupport { /** * */ private static final long serialVersion

无语中 第一次用struts2 与spring2.5整合出现一打错误 麻烦大侠写看哈

问题描述 Contextinitializationfailedjava.lang.NoClassDefFoundError:org/springframework/context/support/AbstractRefreshableConfigApplicationContextatjava.lang.ClassLoader.defineClass1(NativeMethod)atjava.lang.ClassLoader.defineClass(UnknownSource)atjava.s

Struts2注解详解

一.配置web.xml <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>actionPackages</param-name>

struts和spring和hibernate报下面的异常,有大神知道么?谢谢。

问题描述 struts和spring和hibernate报下面的异常,有大神知道么?谢谢. Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in Servlet

Spring Aop实例之AspectJ注解配置

       上篇博文<Spring Aop实例之xml配置>中,讲解了xml配置方式,今天来说说AspectJ注解方式去配置spring aop.        依旧采用的jdk代理,接口和实现类代码请参考上篇博文.主要是将Aspect类分享一下: package com.tgb.aop; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lan

struts2注解(转)

一.配置web.xml <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>actionPackages</param-name>

基于struts2的ssh框架整合错误

问题描述 Exceptionstartingfilterstruts2Unabletoloadconfiguration.-action-file:/C:/Program%20Files/Tomcat%206.0/webapps/demostruts2/WEB-INF/classes/struts.xml:7:68atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.