站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题request.getParameter("")得不到值的问题

request.getParameter("")得不到值的问题

摘要: request.getParameter("")得不到值的问题


问题描述:
在A.JSP中有一个超级链接 update,点击以后跳转到B.JSP中.

然后地址栏中显示 .../b.jsp?teamid=1008 .

在B.JSP中使用JSP语句
<%
String tid = request.getParameter("teamid");
if (tid == null)
out.println("error");
%>

问题: 我为什么取不到teamid的值呢?


自己顶


b.jsp还是B.jsp
分大小写的,页面能够打开??


页面可以打开,大小写是手误.


你看看别的错误吧,如果是这样传输我肯定这个能传输过去,你看看也许是别的问题,时不时中间又什么其他的步骤什么的


通过超级链接可以接受到数据吗?
不需要在A.jsp中写出POST方法吗?
还有tid == null好像没什么用吧 应该改为tid.equals("")


http://218.75.241.186/caiji/yk/a.jsp?teamid=1008
试试,没问题


几位大哥的建议我都看了,没有适合我的.我把B.JSP的代码贴出来,大家看看.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>


HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<head>

Update Expert Team Infomation
</head>
<body style="font-family: Arial; font-size: small; font-weight: bolder">
<table width="778" align="center">
<tr>
<td background="images/fba_01.jpg" height="125"></td>
</tr>
<tr>
<td background="images/etbg.jpg" height="50"></td>
</tr>
</table>
<table width="778" align="center">
<tr>
<td align="left" style="border: ; color: blue; font-family: Arial; font-size: medium; font-weight: bold">Team Leader</td>
</tr>
</table>

<form name="frm1" action="AddExpertTeam.jsp" method="post">
<input type="hidden" name="teamid" value="<%=request.getParameter("teamid") %>">
<input type="hidden" name="update" value="1">
<table width="600" align="center" style="border: 1 solid #0000a0">
<%
et.connectDB("brtc1","brtc","");
String tid = request.getParameter("teamid");
if (tid == null)
out.println("no team id");

A.JSP中不是链接,写错了,是一个JAVASCRIPT的函数:代码如下:
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>


HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<head>

Update Project Infomation
</head>
<script language="javascript">
function upExp(id)
{
window.open("updateExpertTeam.jsp?teamid="+id,"UpdateExpertTeam","menubar,statusbar,location,scrollbar,resizable=yes");
}
function upStaff(id)
{
window.open("updateStaffTeam.jsp?teamid="+id,"UpdateStaffTeam","menubar,statusbar,location,scrollbar,resizable=yes");
}
</script>


LZ两个页面用的字符集不一样啊.
都用GBK试试.
String tid =(String)request.getParameter("teamid");


关注!


谢谢 Netself ,原来是字符集不一样造成的.


你先在你的SCRIPT里看下有没有获取ID的值...如果没有的话说什么都没有用;

另外把你的script放进<head>里看看,最后再看看你的字符集,都换成GBK或GB2312

很就没有这么写JSP了.也建议楼主用Struts框架或别的框架.


谢谢 SKer , 不好意思,结贴的时候没有看到你.希望不要介意 :)


↑返回目录
前一篇: 求一js语句(简单,但我不会。呵呵)
后一篇: struts插‘中文数据’到SQLSERVER中遇到的问题!