Struts2约定插件(m2eclipse/geronimo)

Struts2约定插件(m2eclipse/geronimo),struts2,Struts2,使用约定插件似乎非常简单,但我无法使其正常工作:( 我使用的是struts2版本2.2.3 我有一个名为com.medicis.actions的包,其中包含扩展ActionSupport的UserAction。 我没有任何struts.xml文件 我在maven配置上设置了约定插件依赖项(我还检查了生成的war文件) 这是我的web.xml: <display-name>Starter</display-name> <context-param> &

使用约定插件似乎非常简单,但我无法使其正常工作:(

我使用的是struts2版本2.2.3

我有一个名为com.medicis.actions的包,其中包含扩展ActionSupport的UserAction。 我没有任何struts.xml文件 我在maven配置上设置了约定插件依赖项(我还检查了生成的war文件) 这是我的web.xml:

<display-name>Starter</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext*.xml</param-value>
</context-param>

<!-- Filters -->
<filter>
    <filter-name>action2-cleanup</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter>
    <filter-name>action2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
    <filter-name>action2-cleanup</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>action2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Listeners -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>jspSupportServlet</servlet-name>
    <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
    <load-on-startup>5</load-on-startup>
</servlet>

<!-- Welcome file lists -->
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>
启动器
上下文配置位置
classpath*:applicationContext*.xml
行动2清理
org.apache.struts2.dispatcher.ActionContextCleanUp
网站
com.opensymphony.module.sitemesh.filter.PageFilter
行动2
org.apache.struts2.dispatcher.FilterDispatcher
行动2清理
/*
网站
/*
行动2
/*
org.springframework.web.context.ContextLoaderListener
jspSupportServlet
org.apache.struts2.views.JspSupportServlet
5.
index.jsp
我尝试使用和不使用action2筛选器的init参数:

<init-param>
   <param-name>actionPackages</param-name>
   <param-value>com.medicis.actions</param-value>
</init-param>

行动包
com.medicis.actions
我在struts.property文件中设置了此属性:

struts.action.extension=action

仍然无法使用localhost:8080/starter/user启动操作。操作:

没有为命名空间/和操作名用户映射的操作

我真的不知道出了什么问题,我甚至下载了一个简单的例子,也没有任何结果

这可能是由于eclipse、m2eclipse、maven wtp或geronimo造成的配置问题吗

如果你需要更多的信息,告诉我,我会尽快提供给你

  • 在“src”文件夹中创建struts.properties
  • 从下面复制并粘贴代码:

    struts.convention.package.locators = actions
    struts.convention.action.suffix = Controller
    struts.convention.action.mapAllMatches = true
    
    package com.example.actions;
    
    import org.apache.struts2.interceptor.validation.SkipValidation;
    import org.apache.struts2.rest.DefaultHttpHeaders;
    import org.apache.struts2.rest.HttpHeaders;
    import com.opensymphony.xwork2.ActionSupport;
    
    public class UserController extends ActionSupport {
    
        public String index(){
            return SUCCESS
        }
    
    }
    
  • 在com.example.actions中创建名为IndexController的类

  • 从下面复制并粘贴代码:

    struts.convention.package.locators = actions
    struts.convention.action.suffix = Controller
    struts.convention.action.mapAllMatches = true
    
    package com.example.actions;
    
    import org.apache.struts2.interceptor.validation.SkipValidation;
    import org.apache.struts2.rest.DefaultHttpHeaders;
    import org.apache.struts2.rest.HttpHeaders;
    import com.opensymphony.xwork2.ActionSupport;
    
    public class UserController extends ActionSupport {
    
        public String index(){
            return SUCCESS
        }
    
    }
    

  • 您还需要在WEB-INF/content/user/index.jsp中创建jsp文件

    是的,我使用这个插件,它也找不到任何操作。。。