0

我正在创建一个使用 Spring Social 链接到 facebook 的程序。它加载这个 JSP 登录页面,然后重定向到我的应用程序页面。登录页面的 url 是http://localhost:8080/my-app/signin. 单击登录按钮后,它会重定向到http://localyhost:8080/my-app/#_=_. 我想要发生的是,当它重定向网址末尾的主页时,我想添加一个包含唯一编号的变量。所以我希望它看起来像http://localhost:8080/my-app/1234567而不是http://localhost:8080/my-app/#_=_.感谢您的帮助。

登录页面

<%@ page session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <title>Sign In</title>
    </head>
    <body>
        <form action="<c:url value="/signin/facebook" />" method="POST">
            <button type="submit">Sign in with Facebook</button>
            <input type="hidden" name="scope" value="email,publish_stream,offline_access" />
        </form>
    </body>
</html>

主页

<%@ page session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <title>Home</title>
    </head>
    <body>
    <ul>
        <li><a href="<c:url value="/signout" />">Sign Out</a></li>
    </ul>
        <p>${number}</p>
    <h3>Your Facebook Friends</h3>
    <ul>
    <c:forEach items="${friends}" var="friend">
        <li><img src="http://graph.facebook.com/<c:out value="${friend.id}"/>/picture" align="middle"/><c:out value="${friend.name}"/></li>
    </c:forEach>
    </ul>   
    </body>
</html>

家庭控制器

@RequestMapping(value = "/", method = RequestMethod.GET)
    public String home(Model model) throws IOException {

           List<Reference> friends = facebook.friendOperations().getFriends();
           FacebookProfile profile = facebook.userOperations().getUserProfile();
           String userID = facebook.userOperations().getUserProfile().getId();
           model.addAttribute("friends", friends);
           String accessToken = connectionRepository.getPrimaryConnection(Facebook.class).createData().getAccessToken();
            System.out.println(accessToken);
        return "home";
    }
4

1 回答 1

0

基本上,您似乎想在单击登录按钮时更改表单的提交 URL。

由于单击按钮是在客户端站点上发生的事情,因此您将需要一个 java 脚本,该脚本将在登录按钮的单击事件中调用,获取 jsp 的表单元素并将其提交 URL 修改为您想要的 URL .

如果那是您正在寻找的内容,那么下面的链接应该会有所帮助,就像正确的 Google 搜索中的类似链接一样:

样本

于 2013-09-01T18:11:43.250 回答