【问题标题】:how to call two submit buttons in spring form, one calls j_spring_security_check and another one calling controller method如何在spring表单中调用两个提交按钮,一个调用j_spring_security_check,另一个调用控制器方法
【发布时间】:2014-01-21 16:26:18
【问题描述】:

如何在spring表单中调用两个提交按钮, 一个按钮调用 j_spring_security_check,另一个按钮调用控制器方法。 以下是登录表单

                <form action="../../j_spring_security_check" method="post" >

         <div class="right">
          <ul>
            <li>
              <spring:message code="label.userName" text="UserName" />
              <input id="j_username" name="j_username" type="text" />
        <form:errors path="firstName" cssclass="error">    </form:errors>
            </li>
            <li>
              <spring:message code="label.password" text="Password" />
              <input id="j_password" name="j_password" type="password" />
              <form:errors path="password" cssclass="error"></form:errors>
            </li>
            <li>

              <input type="submit" value="Login" />&nbsp;&nbsp;


            </li>
          </ul>
        </div>
        </form> 
             <form action="/portal/main/resetForgetPassword" method="POST">
                 <input type="submit" value="ForgetPassword">  
              </form> 

提前感谢

【问题讨论】:

  • 在 Spring Security 中,在转到您的控制器方法之前,它会调用 j_spring_security_check 被拦截的 url,所以我想不需要两个提交按钮。
  • @Shoaib Chikate:是的,但是在我的表单页面中,会有一个登录按钮和另一个忘记密码按钮。所以当我点击忘记密码时,它不会重定向到控制器...
  • 那它重定向到谁了??
  • @Shoaib Chikate:
    这些是我的行动。我点击忘记密码按钮。但它不会去控制器..请帮助我...

标签: spring spring-security


【解决方案1】:

我猜你的问题是,对于每个 URL,它都会变成 Spring 的安全形式。

所以你需要允许一些 url 以便它不应该去 j_spring_security_check

您可以在 security.xml 中执行此操作(无论该文件的名称是什么)。

   <intercept-url pattern="/portal/main/forgetPassword*" access="permitAll" />
   <intercept-url pattern="/*" access="hasRole('ROLE_ADMIN_ASSUMED')">

还有在你的 html 代码中

  <a href="/portal/main/resetForgetPassword">Forget Password</a>

【讨论】:

  • 谢谢你的回复..我试过这种方式,但它不会去控制器..我正在使用瓷砖框架和弹簧,jsp
  • 我已添加我的登录表单..请检查。
  • 尝试将链接忘记密码设为忘记密码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多