简体   繁体   English

如何将JSF表单数据传递给Spring Controller

[英]How to pass jsf form data to spring controller

I have Login form in jsf and a Login model that contains the fields 我在jsf中有Login表单,并且其中包含字段的Login模型

userID 
password

I want to pass form data to a Spring controller and set the login model using @modeattribute of Spring and call service of dao to authenticate the user. 我想将表单数据传递给Spring控制器,并使用Spring的@modeattribute和dao的调用服务来设置登录模型以验证用户身份。

I guess this is the way to do that : 我想这是做到这一点的方法:

first add this to your faces-config.xml : 首先将此添加到您的faces-config.xml:

<application>       
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

second write your controller like this : 第二个这样写你的控制器:

@Controller
@Scope(value="session")
public class SomeContoller{

    private String userID;
    private String password;

    public String validate() {

       //some traitement on userID and password

       return "somepage";
     }

 //getters and setters ...
}

last of all add your dependencies : for spring and SpringBeanFacesELResolver 最后添加您的依赖项:对于spring和SpringBeanFacesELResolver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM