他们在各个地方都说您应该使用@ManagedProperty 来获取请求参数。问题是我尝试从请求字符串中获取令牌,但它始终保持为空。
页面所在的链接如下所示:
http://example.com/faces/Check.xhtml?token=EC-8AT450931P272300C&ID=VKEFF29XNGNJG
豆子:
@Named(value = "bean")
@RequestScoped
public class Bean implements Serializable {
    @Inject
    private AccountBean account;
    @Inject
    private Service web;
    @ManagedProperty(value = "#{param.token}")
    private String token;
    @ManagedProperty(value = "#{param.ID}")
    private String id;
    @PostConstruct
    public void init() {
        System.out.println("token: " + token);
    }
这页纸
<ui:define name="content">
    <h:form>
        <pou:commandButton action="#{bean.test()}" value="complete"/>
    </h:form>
</ui:define>
以及我尝试过的其他事情:
Map<String, String> e = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
这也不包含请求参数。可以获取请求的所有 facesContext 事物也是如此。
帮助将不胜感激。
PS我不能改变后面的任何东西?导致它从我无法触及的程序中调用