Topic: 在servlet中跳转到另外一个servlet时候如果传递参数?

  Print this page

1.在servlet中跳转到另外一个servlet时候如果传递参数? Copy to clipboard
Posted by: wmgreat
Posted on: 2003-04-01 19:46

我在servlet中跳转到一个另外一个servlet,语法如下:
response.sendRedirect(request.getContextPath()+"/getsinglecontentinfo?processid="+processid+"&content="+content);
但是始终只有一个参数(content)能被传递到下一个serlvert。
不知道是什么原因

2.Re:在servlet中跳转到另外一个servlet时候如果传递参数? [Re: wmgreat] Copy to clipboard
Posted by: snowbug
Posted on: 2003-04-02 04:58

Please post the code and the test data. Maybe the value of the processid is null? Try to add another parameter and see if you can retrieve it.

One thing you should always do is to encode the parameter values:
response.sendRedirect(request.getContextPath()+"/getsinglecontentinfo?processid="+URLEncoder.encode(processid)+"&content="+URLEncoder.encode(content));

The above code is for JDK 1.2 or 1.3. In JDK 1.4, you need to use Encoder.encode(string, charset);

3.Re:在servlet中跳转到另外一个servlet时候如果传递参数? [Re: wmgreat] Copy to clipboard
Posted by: floater
Posted on: 2003-04-02 05:33

print your processid before you redirect to see whether it's null.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923