简体   繁体   中英

How can I inject dependencies into a javax.faces.context.ExceptionHandler using Spring?

I have a JSF application using PrimeFaces 6.2 and Spring 5.1.4. I read, that an exception handler can be defined in the faces-config.xml like this:

<factory>
    <exception-handler-factory>my.package.MyExceptionHandlerFactory</exception-handler-factory>
</factory>

I wondered how I could get the dependencies injected into an ExceptionHandlerFactory and ExceptionHandler ?

You can't do this out of the box. It would be possible by creating an "spring aware" ExceptionHandlerFactory and create the ExceptionHandler instance via Spring but i would just get the beans manually in your ExceptionHandler like: Best way to manually pull a spring bean?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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