Nella mia classe bean di filtro, ho aggiunto alcune dipendenze con i bean (con annotazione @Autowired
). Ma nel metodo doFilter()
, tutti i miei fagioli di dipendenza hanno nulla ...Utilizzo di alcuni bean nella classe Filter bean?
public class FacebookOAuth implements Filter
{
@Autowired
private BusinessLogger logger;
@Autowired
private IUserSessionInfo userSessionInfo;
@Autowired
private FacebookOAuthHelper oAuthHelper;
public void init(FilterConfig fc) throws ServletException
{
// Nothing to do
}
public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) throws IOException, ServletException
{
// HttpServletRequest req = (HttpServletRequest)sr;
HttpServletResponse res = (HttpServletResponse) sr1;
String code = sr.getParameter("code");
if (StringUtil.isNotBlankStr(code))
{
String authURL = this.oAuthHelper.getAuthURL(code);
this.oAuthHelper è uguale a zero (e altri fagioli dipendenza a) ...
Potrebbe aiutarmi?
Infatti non utilizzo nozione MVC sul lato server (Spring). Per il mio cliente lato utilizzo la tecnologia Flex e il servlet BlazeDS comunica con il mio server.
Quindi, questo è il motivo, io uso il concetto di bean filtro.
Quindi, come posso gestire il mio concetto di bean di sessione nel mio bean Filtro?
Skaffman,
ho implementato la tua idea, quindi aggiorno il mio application.xml con:
<bean id="FacebookOAuthHandler" class="com.xx.FacebookOAuthHandler" />
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/fbauth">FacebookOAuthHandler</prop>
</props>
</property>
</bean>
e la mia FacebookOAuthHandler classe:
public class FacebookOAuthHandler extends AbstractController
{
@Autowired
private BusinessLogger logger;
@Autowired
private IUserSessionInfo userSessionInfo;
@Autowired
private FacebookOAuthHelper oAuthHelper;
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// TODO
return null;
}
Ma, questo metodo handleRequestInt ernal non viene mai chiamato quando il mio URL è: http://xx.xx.xx.xx/MyApp/fbauth
Come si presenta la configurazione della molla? – GaryF