我尝试了这些简单的 java 和 xhtml 代码,但它不起作用。
@ManagedBean(name = "connecter")
@RequestScoped
@SessionScoped
public class Connecter
{
int nombre;
public Connecter()
{
//在这里我将输入我从 Graph API Explorer 获得的访问令牌//
FacebookClient facebookClient = new DefaultFacebookClient("");
Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class, Parameter.with("fields", "id, name,picture"));
nombre = myFriends.getData().size();
}
public int getNombre()
{
return nombre;
}
public void setNombre(int nombre)
{
this.nombre = nombre;
}
}
//这是我的 web.xml 文件,包括 servlet 映射。那么如何检查 url 是否在 Faces Servlet URL 中?
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>..</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
..</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
..'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
..
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>