日期:2014-05-18  浏览次数:20670 次

在JSP里调用另外一个页面传入一个参数,怎么取得返回值
谢谢,初学不太懂,想用同步的,所以AJAX可能用不到,谢谢

------解决方案--------------------
调用页面怎么会有返回值呢?一般在Action中处理吧。
对问题的描述不大清楚。
------解决方案--------------------
dasf
------解决方案--------------------
jsp中 <%、%> 之间的scriptlet代码是服务端代码,js代码是客户端代码,页面生成时是根据scriptlet代码顺序解析的,scriptlet中无法获取当前某个form中元素的值。直接用document.form1.text1.value这种代码是非法的。
解决办法可以将页面提交一次,form的action可以设成当前页面,这样提交完成以后又回到当前页面,可以用request.getParameter()方法获取form中元素的值。
如果不想提交整个页面可以用ajax实现。
------解决方案--------------------
servlet
------解决方案--------------------
实在 不知道你说的什么意思
------解决方案--------------------
楼主说的是不是这个意思,就是当发生页面跳转时一同传递了参数,跳转到的页面是如何接受传来的参数的??是吧
如果是我有实例也是我刚刚学会的。
=========
这是发生跳转的.jsp文件
<%@ page contentType= "text/html; charset=gb2312 "%>
<%@ page import = "java.util.*,java.sql.Timestamp,myonepiece.*,myonepiece.db.* "%>
<%

request.setCharacterEncoding( "gb2312 ");
String pirateName =request.getParameter( "pirateName ");
String password = request.getParameter( "password ");
Pirate p1=new Pirate();
p1=DbPirate.getPirate(pirateName);
if (p1!=null){
if(pirateName !=null && password!=null &&
p1.getPassword().equals(password))
{
response.sendRedirect( "index.jsp?pirateName= "+pirateName);
//这句传参数的*******

} else
{
response.sendRedirect( "maintain/include/1.jsp ");

}
}else{
response.sendRedirect( "maintain/include/1.jsp ");
}
%>
========================
跳转到的页面.JSP
<%
request.setCharacterEncoding( "gb2312 ");
String pirateName =request.getParameter( "pirateName ");
                       //这一句用变量接受参数的*******
if (pirateName==null){
pirateName= "海上漂流者 ";
}

%>
<html xmlns= "http://www.w3.org/1999/xhtml ">
.......
<p> <span class= "STYLE22 "> <%=pirateName%> </span> </p> <%--这句使用变量的--%>
.......
</html>
======================================================
我也是初学者呀,刚会的