不从jsp调用Spring Controller

时间:2013-03-06 14:54:59

标签: spring jsp spring-mvc spring-security

我正在尝试为我的应用程序实现忘记密码功能。

登录前,如果用户忘记密码,他可以恢复。 recoverPassword jsp文件读取电子邮件ID并将密码发送到emailID。

我的forgotPassword spring Controller未从JSP文件中调用,每当用户点击Recover Button时,login.jsp文件就会再次加载。

我们正在使用Spring Security 3.0 我在登录页面上添加了ForgotPassword Hyperlink,它打开了一个JSP文件。

recoverPass.jsp

<form name="f" action="<c:url value="/all/recoveryPassword/pass" />" method="post">
        <div class="row clear">
            <div class="value">Enter your email:</div>
            <div class="parameter">
                <input type="text" name="email"/>
            </div>
            <div style="color: #FF0000;">${message}</div>
        </div>

        <br/>

        <div class="submit"><input type="submit" name="Recover" value="Recover"/>
        </div>

        <div>
            <a href="<c:url value="/jsp/login.jsp" />">Log In</a>
        </div>
    </form>

RecoverPasswordController.java

@Controller
@RequestMapping("/recoveryPassword")
public class RecoveryPasswordController  extends BaseController {

    @Autowired
    private UserDAO usersDao;    

    @RequestMapping(value = "/pass", method =RequestMethod.POST)
    public String recoverPassword(@RequestParam("json") String json, ModelMap model){
       //Code to read the email ID check DB and send a new password in email         
        try {

        } catch (Exception e) {            
            model.addAttribute("error", true);
            return "d"; 
        }       
        return "redirect:/recoveryPasswordSuccess";
    }
}

要从Spring Security中排除Controller,我在 applicationContext-security.xml

中添加了以下内容
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

      <http realm="Contacts Realm" use-expressions="true">
            <intercept-url pattern="/all/recoveryPassword/*" filters="none"/>
            <intercept-url pattern="/" access="permitAll"/>
    .....

最后是 web.xml

<servlet>
        <servlet-name>abc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/classes/applicationContext.xml,/WEB-INF/classes/remote-servlet.xml</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

<servlet-mapping>
        <servlet-name>abc</servlet-name>
        <url-pattern>/abc/*</url-pattern>
    </servlet-mapping>

任何人都可以帮助我解决此问题,我一直在努力解决此问题。

0 个答案:

没有答案