ADF中的面孔无法获取请求参数 [英] Faces in ADF can't get the request parameters

查看:69
本文介绍了ADF中的面孔无法获取请求参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有Faces 1.2的ADF Web应用程序

I have an ADF web application with Faces 1.2

在我的托管bean中,我试图访问发布请求的参数,但是总是获取null.

In my managed bean I am trying to access the parameters of the post request, but always getting null.

这是我要发布到Faces的我的发布表单:

This is my post form that I am posting to the Faces:

<form name="input" action="http://127.0.01:7072/myapplication/faces/login.jspx" method="post">
   <input type="hidden" name="user" id="user" value="myUserName"/>
   <input type="submit" value="Submit"/>
</form>

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("user");

FacesContext.getCurrentInstance().getExternalContext().getRequest().getParameter("user");

但是我总是得到null,并且我得到的形式的方法是:GET,很奇怪!

But I always get null and the method of the form I get is: GET, strange!

推荐答案

当您请求以下URL时:

when you make a request for a URL like:

http://server/faces/somepage.jspx

ADF框架通过"HTTP错误302临时移动"响应来响应您,并将您重定向到网址,例如:

ADF framework respone you by a "HTTP Error 302 Moved temporarily" response and redirect you to the URL like :

http://server/faces/somepage.jspx? _adf.ctrl-state = 888888& _afrLoop = 9999999

因此您的第一个POST请求被忽略,浏览器将另一个请求发送到ADF作为响应返回的新URL,因此,由于POST方法在请求正文中发送参数,浏览器不会在新的Get请求中重新发送它们 因此,我认为您无法在ADF页面旁边直接获取参数! :(

so your first POST request is omit and browser send an other request to the new URL that ADF returned in response, so because POST method send parameter in the request body the browser dont resend them in new Get request so i think there is no way for you to get parameters direcly in side the ADF page ! :(

但是我认为最好的方法是创建一个 Servlet ,并在其中添加参数,然后将其置于 session ,然后重定向用户从servlet到您的ADF页面:)

but i think the best way is to create a Servlet and get you param in it and put them to session and then redirect the user from servlet to your ADF page :)

这篇关于ADF中的面孔无法获取请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆