[英]how to get parameters from the URL and pass it as a HashMap key JSF? Environment Glassfish , Java 7 , Icefaces
I need pass a key parameter trought URL like this: http://localhost:8080/ProvAt-war/monitor.jsf?&id=77-6 And you show the list based on the parameter received 77-6 I get the parameter through javascript funtion我需要像这样传递一个关键参数 trought URL: http://localhost:8080/ProvAt-war/monitor.jsf?&id=77-6然后你根据收到的参数显示列表 77-6 我通过javascript 函数
<ui:repeat value="#{provatBean.descargandoHashMap.get(QueryString)}" var="desc" rendered="#{not empty provatBean.descargandoHashMap.get('QueryString')}">
<h:outputText value="#{desc.descProveedor}"/>
<h:outputText value="EDI" rendered="#{desc.id_grupo/>
<h:outputText value=" NO-EDI" rendered="#{desc.id_grupo/>
<h:outputText value="PERECEDEROS" rendered="#{desc.id_grupo}"/>
</ui:repeat>
var QueryString = function () {
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = decodeURIComponent(pair[1]);
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(decodeURIComponent(pair[1]));
}
}
alert(vars[1]);
return vars[1];
}();
The parameters of a request are already available via EL via #{param['key']}
, where key
is the parameter name of interest.请求的参数已经可以通过 EL 通过
#{param['key']}
,其中key
是感兴趣的参数名称。 You don't need two dozen lines of JavaScript.您不需要两打 JavaScript 代码。 And they're already decoded.
而且它们已经被解码了。
This is rather basic.这是比较基本的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.