我还是不太明白 //这个就是A页面的按钮 public String button1_action() { //待办事项:执行此操作。返回值为某个导航 //情况名称;如果返回值为空,将返回至同一页面 int a = 5;//比如这个就是要传的变量 return "case1"; } B页面 public void init() { // Perform initializations inherited from our superclass super.init(); // Perform application initialization that must complete // *before* managed components are initialized // TODO - add your own initialiation code here //我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。 //int b; //就是简单的把A页面的a赋值给b,该怎么做呢???????????????
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization"> // Initialize automatically managed components // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("simplyresult Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); }
// </editor-fold> // Perform application initialization that must complete // *after* managed components are initialized // TODO - add your own initialization code here }
哥,很小心的问你一句,java页面是什么??不是JSP么?
我的是visual web jsf netbean里面项目新建一个visual web jsf页 出来以后有设计视图 JSP JAVA视图 JSP视图里的代码我看不懂 我都是点JAVA视图往里写东西的
于是谁告诉我怎么A页面点个按钮把A页面的一个值传给B页面阿。 //这个就是A页面的按钮 public String button1_action() { //待办事项:执行此操作。返回值为某个导航 //情况名称;如果返回值为空,将返回至同一页面 int a = 5;//比如这个就是要传的变量 return "case1"; } B页面 public void init() { // Perform initializations inherited from our superclass super.init(); // Perform application initialization that must complete // *before* managed components are initialized // TODO - add your own initialiation code here //我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。 //int b; //就是简单的把A页面的a赋值给b,该怎么做呢???????????????
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization"> // Initialize automatically managed components // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("simplyresult Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); }
// </editor-fold> // Perform application initialization that must complete // *after* managed components are initialized // TODO - add your own initialization code here }
在B页面用<% request.getParameter("var");%>即可取的变量值
A.jsp
<form method="post" name="form1" action="B.jsp">
<input type="hidden" name="aa" value="aa"/>
<input name="提交" type="submit" value="提交" />
</form>
B.jsp
<%String aa=request.getParameter("aa"); %>
用户名:<input type="text" name="userName">在JAVA类里面 就可以
String str=request.getparamter("userName");转到B页面
用户名:${requestScope.userName}
getParameter("param")函数为 获取参数param的值
该函数是 request的函数,而加上request就是限定改参数param需要是请求范围内的参数
<form method="post" name="form1" action="B.jsp?变量名a=<%=变量a %>">b页面
string a = request.getParameter("变量a");
取参数名为name的值。
//这个就是A页面的按钮
public String button1_action() {
//待办事项:执行此操作。返回值为某个导航
//情况名称;如果返回值为空,将返回至同一页面 int a = 5;//比如这个就是要传的变量 return "case1";
}
B页面
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
//我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。
//int b;
//就是简单的把A页面的a赋值给b,该怎么做呢???????????????
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("simplyresult Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
哥,很小心的问你一句,java页面是什么??不是JSP么?
netbean里面项目新建一个visual web jsf页 出来以后有设计视图 JSP JAVA视图 JSP视图里的代码我看不懂 我都是点JAVA视图往里写东西的
//这个就是A页面的按钮
public String button1_action() {
//待办事项:执行此操作。返回值为某个导航
//情况名称;如果返回值为空,将返回至同一页面 int a = 5;//比如这个就是要传的变量 return "case1";
}
B页面
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
//我要B页面一打开初始化的时候就把a值传过来所以代码应该是写在这个位置。
//int b;
//就是简单的把A页面的a赋值给b,该怎么做呢???????????????
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("simplyresult Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
String str=(String)request.getparamter("userName");