简体   繁体   English

在JSF中使用Spring控制器

[英]Use of Spring controller with JSF

I am using JSF primefaces with GAE/Java.When I moved to spring security framework, the controller has no effect in the application as jsf directly go to java backing bean. 我将JSF primefaces与GAE / Java一起使用。当我转移到spring安全框架时,由于jsf直接转到java后备bean,因此控制器对应用程序没有影响。 So can anyone suggest how can I use spring controller effectively with JSF to follow MVC architecture.Thanks in advance! 因此,任何人都可以建议我如何在JSF中有效地使用spring控制器来遵循MVC架构。

Any better security framework can I add instead of Spring? 我可以添加任何更好的安全框架来代替Spring吗?

JSF does follow MVC architecture - badly, but it does it. JSF 确实遵循MVC架构-很糟糕,但是确实做到了。

Why do you think you need Spring for web MVC? 为什么您认为Web MVC需要Spring? I'd say you should either use JSF or Spring web MVC, but not both at the same time. 我会说您应该使用JSF或Spring Web MVC,但不能同时使用两者。 (I'd also recommend Spring over JSF.) (我还建议在JSF上使用Spring。)

Spring has a security framework, but it's much more than that. Spring有一个安全框架,但不仅限于此。

The question to ask is: what does "better" mean to you? 要问的问题是:“更好”对您意味着什么? What problems are you having with Spring security? Spring安全性有什么问题?

If you're using it as soulcheck recommends below, then I'd say that you should wire in JSF and have a DispatcherServlet along side it to deal with file upload URLs. 如果您按照下面的灵魂检查建议使用它,那么我想说您应该连接JSF并在它旁边附带一个DispatcherServlet来处理文件上传URL。 Annotate Controllers only for non-JSF URLs and it should work. 仅对非JSF URL注释控制器,它应该可以工作。

the controller has no effect in the application as jsf directly go to java backing bean 控制器对应用程序没有影响,因为jsf直接转到Java后备bean

You have to let it dispatch the request to /j_spring_security_check . 您必须让它将请求调度到/j_spring_security_check

public void login() throws IOException {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    externalContext.dispatch("/j_spring_security_check");
    facesContext.responseComplete();
}

See also 也可以看看

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

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