首页 \ 问答 \ 为什么我得到了没有针对命名空间/动作名称loginAction映射的动作?(why am i getting There is no Action mapped for namespace / and action name loginAction?)

为什么我得到了没有针对命名空间/动作名称loginAction映射的动作?(why am i getting There is no Action mapped for namespace / and action name loginAction?)

我有一个Struts 2 + Hibernate + Spring Eclipse Web应用程序。

它最初构建为使用Tomcat 7.0运行,但是当我尝试将其迁移到WeblLogic 12c时,我得到了异常:“没有映射名称空间/操作名称loginAction的Action。”

奇怪的是,如果我从eclipse启动应用程序以在Weblogic上运行它可以正常工作,但如果我导出战争并手动部署它,我会得到上面提到的错误。 在我的struts.xml中,我有几个配置,但大多数struts配置都是注释。

这是我的struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apa che.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.action.excludePattern" value="/rest/.*?" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.multipart.maxSize" value="104857600" />
    <package name="mi-paquete" extends="struts-default">
        <result-types>
            <result-type name="tiles"
                class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>
        <interceptors>
            <interceptor name="LoginInterceptor"
                class="com.proximate.www.pushmate.interceptors.LoginInterceptor" />
            <interceptor-stack name="loginStack">
                <interceptor-ref name="LoginInterceptor" />
                <interceptor-ref name="defaultStack" />
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="loginStack" />
        <global-results>
            <result name="loginAction">/jsp/template/loginLayout.jsp</result>
            <result name="errorAction">/jsp/error/error.jsp</result>
        </global-results>
        <action name="olvidoContrasenia"
            class="com.proximate.www.pushmate.action.OlvidoContraseniaAction">
            <result name="formResult">/jsp/template/olvidoContrasenaLayout.jsp</result>
        </action>
    </package>
</struts>

以下是我的登录操作的摘录:

@ParentPackage("mi-paquete")
@Action(value="loginAction")
@InterceptorRefs({
    @InterceptorRef(value="defaultStack", params = {"excludeMethods","validaUsuario"})
})
@Results({
    @Result(name="success", location="/jsp/template/loginLayout.jsp"),
    @Result(name=ActionsConstants.ERROR, type="tiles", location=ActionsConstants.URL_ERROR),
    @Result(name = "welcome", type = "redirectAction", location = "welcomeAction.action"),
    @Result(name = "registroUsuario", location = "/jsp/template/concluyeRegistroLayout.jsp"),
})
public class LoginAction extends ActionSupport implements SessionAware, ServletRequestAware {

    /**
     * 
     */
    private static final long serialVersionUID = 1218879876500264583L;
    private static final Logger logger = Logger.getLogger(LoginAction.class.getName());
    private Login loginObj;
    private static String URLAplication = null;
    private static String URLReportes = null;

    @Autowired
    private IUsuarioService usuarioService;

    @Autowired
    private IMenuDAO menuUsuarioDAO;

    @Autowired
    private ILogDAO logDAO;

    Map<String, Object> session;
    HttpServletRequest request;

    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        return validaUsuario();
    }
}

有谁知道为什么struts2注释失败???? 提前致谢。


I got an Struts 2 + Hibernate + Spring Eclipse web application.

It was originally build to run with Tomcat 7.0, but when I try to migrate it to WeblLogic 12c I get the exception:"There is no Action mapped for namespace / and action name loginAction."

The weird thing is that if I launch the application from eclipse to run on Weblogic it works fine, but if I export the war and deploy it manually I get the previous error mentioned. In my struts.xml I have a couple of configuration, but most of the struts configurations are annotations.

Here is my struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apa che.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.action.excludePattern" value="/rest/.*?" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.multipart.maxSize" value="104857600" />
    <package name="mi-paquete" extends="struts-default">
        <result-types>
            <result-type name="tiles"
                class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>
        <interceptors>
            <interceptor name="LoginInterceptor"
                class="com.proximate.www.pushmate.interceptors.LoginInterceptor" />
            <interceptor-stack name="loginStack">
                <interceptor-ref name="LoginInterceptor" />
                <interceptor-ref name="defaultStack" />
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="loginStack" />
        <global-results>
            <result name="loginAction">/jsp/template/loginLayout.jsp</result>
            <result name="errorAction">/jsp/error/error.jsp</result>
        </global-results>
        <action name="olvidoContrasenia"
            class="com.proximate.www.pushmate.action.OlvidoContraseniaAction">
            <result name="formResult">/jsp/template/olvidoContrasenaLayout.jsp</result>
        </action>
    </package>
</struts>

Here is an excerpt of my login action:

@ParentPackage("mi-paquete")
@Action(value="loginAction")
@InterceptorRefs({
    @InterceptorRef(value="defaultStack", params = {"excludeMethods","validaUsuario"})
})
@Results({
    @Result(name="success", location="/jsp/template/loginLayout.jsp"),
    @Result(name=ActionsConstants.ERROR, type="tiles", location=ActionsConstants.URL_ERROR),
    @Result(name = "welcome", type = "redirectAction", location = "welcomeAction.action"),
    @Result(name = "registroUsuario", location = "/jsp/template/concluyeRegistroLayout.jsp"),
})
public class LoginAction extends ActionSupport implements SessionAware, ServletRequestAware {

    /**
     * 
     */
    private static final long serialVersionUID = 1218879876500264583L;
    private static final Logger logger = Logger.getLogger(LoginAction.class.getName());
    private Login loginObj;
    private static String URLAplication = null;
    private static String URLReportes = null;

    @Autowired
    private IUsuarioService usuarioService;

    @Autowired
    private IMenuDAO menuUsuarioDAO;

    @Autowired
    private ILogDAO logDAO;

    Map<String, Object> session;
    HttpServletRequest request;

    @Override
    public String execute() throws Exception {
        // TODO Auto-generated method stub
        return validaUsuario();
    }
}

Does anyone knows why are the struts2 annotations failing???? Thanks in advance.


原文:https://stackoverflow.com/questions/29291889
更新时间:2024-01-18 15:01

最满意答案

您正在做的是GET请求类型。

需要将参数传递给初始重写变量。

尝试这个:

RewriteRule ^search/([^/]*)/$ /directory/search.php?&q=$1 [L]

要POST数据,不要GET:

RewriteRule ^search /directory/search.php?q=$1 [NC,P]

“P”的作用类似于“L”,因为它停止处理规则,但它也告诉模块该请求应该完整地传递给代理模块(意味着POST数据被保留)。

此外,请确保打开重写引擎,并设置选项。 如果没有重写引擎,它将给你一个500错误。

这就是我通常使用的:

Options +FollowSymlinks
Options -MultiViews 
RewriteEngine On
RewriteBase /
ErrorDocument 404 /error.php
ErrorDocument 300 /error.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

What you are doing is a GET request type.

Need to pass the parameter to the initial rewrite variable.

Try this:

RewriteRule ^search/([^/]*)/$ /directory/search.php?&q=$1 [L]

To POST data, not GET:

RewriteRule ^search /directory/search.php?q=$1 [NC,P]

"P" acts like "L" in that it stops processing rules but it also tells the module that the request should be passed off to the proxy module intact (meaning POST data is preserved).

Also, make sure you turn the rewrite engine on, and set your options. without the rewrite engine on, it will give you a 500 error.

This is what I typically use:

Options +FollowSymlinks
Options -MultiViews 
RewriteEngine On
RewriteBase /
ErrorDocument 404 /error.php
ErrorDocument 300 /error.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

相关问答

更多

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)