我正在使用以下添加的
输入以下网址?用户ID = XBBBB
我正在尝试将XBBBB的UserID一直通过index.jsp到proauth.xhtml并进入我的ProfileAuthorizationBean.java的支持bean。
代码正在逐步完成,但在index.jsp之后,UserID = XBBBB参数将丢失。 IOW,index.jsp中的System.out正在将XBBBB打印到控制台,我相信它会转发到proauth.xhtml。当我在ProfileuthorizationBean中使用HttpServletRequest时,UserID的参数不存在。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>
<html>
<head></head>
<body></body>
<%
request.setCharacterEncoding("UTF-8");
String UserID = request.getParameter("UserID");
if (UserID != null) {
System.out.println(UserID);
response.sendRedirect("proauth.xhtml?UserID=" + UserID);
}
%>
</html>
<!DOCTYPE html>
<html xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<link rel="stylesheet" type="text/css" href="themes/local/tinstyle.css"/>
</h:head>
<script type="text/javascript">
function doSubmit() {
document.getElementById('proAuthForm:proAuthBtn').click();
}
</script>
<h:body onload="doSubmit()">
<h:form id="proAuthForm">
<p:commandButton id="proAuthBtn" value="" action="#{profileAuthorizationBean.doProfileAuth}" ajax="false" />
</h:form>
</h:body>
</html>
public String doProfileAuth() {
String retValue = "landingPage";
try {
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
System.out.println(request.getParameter("UserID"));
.
.
.
} catch (Exception e) {
}
}