其他分享
首页 > 其他分享> > Spring Social ConnectController / connect / facebook出现404错误

Spring Social ConnectController / connect / facebook出现404错误

作者:互联网

我试图让facebook登录名与spring social一起工作.
我已经在Facebook上创建了一个应用程序.

分派器Servlet

   <servlet-mapping>
    <servlet-name>ABC</servlet-name>
    <url-pattern>*.cs</url-pattern>
    </servlet-mapping>

配置xml

<servlet-mapping>
<servlet-name>ABC</servlet-name>
<url-pattern>*.cs</url-pattern>
</servlet-mapping>

<!-- Configure a connection repository through which account-to-provider connections will be stored --> 
<beans:bean id="connectionRepository" class="org.springframework.social.connect.jdbc.JdbcConnectionRepository">
<beans:constructor-arg ref="dataSource" />
<beans:constructor-arg ref="textEncryptor" />
</beans:bean>



<!-- Configure a Facebook service provider -->
<beans:bean class="org.springframework.social.facebook.connect.FacebookServiceProvider">
<beans:constructor-arg index="0" value="564846465216" />
<beans:constructor-arg index="1" value="f4554iojfjh9iu7km54f54pok5ok4" />
<beans:constructor-arg index="2" ref="connectionRepository" />
</beans:bean>

<beans:bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" factory-method="noOpText" />

<beans:bean class="org.springframework.social.web.connect.ConnectController">
<beans:constructor-arg index="0" value="http://localhost:8080/CitySpanks/" />
</beans:bean>

我指的是这个链接
http://static.springsource.org/spring-social/docs/1.0.0.M2/reference/html/connecting.html

在我的jsp中

<a href="<c:url value="connect/facebook" />">Connect to Facebook</a>

我缺少什么???单击上面的链接时,我不断收到404错误.

谢谢 :)

解决方法:

我不确定您在项目中的位置,但是我认为以下内容很容易忽略…

如果查看spring-social-showcase的示例项目,您会注意到

spring-social-showcase-sec/src/main/webapp/WEB-INF/views/connect

存在以下页面:
status.jsp,facebookConnect.jsp,facebookConnected.jsp.

在示例项目中,当请求以下内容(左)时,它将解析下面的.jsp(右):

"connect/facebook" => Connected => "connect/facebookConnected.jsp"
"connect/facebook" => Not Connected => "connect/facebookConnect.jsp"
"connect"          => "connect/status.jsp"

在此处记录:4.3.1 Displaying a connection page

因此,要使该示例在您的代码中运行,您必须使用上面的.jsp创建相同的目录结构“ WEB-INF / views / connect /”.否则,将找不到404.因此,我相信这是由ConnectController类在幕后解决的,如上面链接的文档所述.

但是,您可能要开始使用spring-social-samples中提供的web.xml配置,一旦掌握了这一点,就从那里开始.

<!-- Processes application requests -->
<servlet>
  <servlet-name>appServlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value></param-value>
  </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
  <servlet-name>appServlet</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

标签:spring-social,facebook,spring,spring-mvc
来源: https://codeday.me/bug/20191031/1977906.html