0

我有一个登录模式。modal(bootstrap) 表单是 header.jsp 的一部分,它包含在每个 JSP 中。如果用户输入错误的用户名/密码,如何将操作错误消息返回到我的模式?

Struts.xml

<action name="authenticate" method="login"
       class="app.resumerepo.in.action.LoginAction">
    <interceptor-ref name="loginCheck" />
    <result name="success" type="redirect">myaccount.action</result>
    <result name="input"> </result>
    <result name="error">/jsp/common/error.jsp</result>
</action>

对于结果“输入”,我应该提到什么,以便我在登录模式上收到操作错误消息?

4

2 回答 2

1
  1. 确保您loginCheck是一个拦截器堆栈,而不是单个拦截器。在后一种情况下,创建一个自定义拦截器堆栈,其中包含您的loginCheck拦截器,或者声明您的拦截器defaultStack等:

    <action name="authenticate" method="login"
           class="app.resumerepo.in.action.LoginAction">
        <interceptor-ref name="loginCheck"   />
        <interceptor-ref name="defaultStack" />
        ...
    
  2. 在您的代码中,没有显示您如何登陆登录页面;顺便说一句,要使其按您的要求工作,只需将input结果配置为返回您来自的 JSP 页面,例如:

    <result name="input">login.jsp</result>
    

    看看这个可能有帮助的例子。

于 2014-10-31T09:38:20.003 回答
0

我将更正拦截器部分,在登录失败时,我重定向到一个 login_error.jsp,我在其中调用相同的模式。它按预期工作。

                    <%@page session="false"%>
                    <%@taglib uri="/struts-tags" prefix="s"%>
                    <%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                    <html>
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                    <title>Insert title here</title>

                    </head>
                    <body style="background-color:#FFF;">
                       <script type="text/javascript">
                        $('#myModal').modal('show'); 
                       </script>

                    </body>
                    </html> 
于 2014-10-31T09:49:32.900 回答