两个方法不能同时用的
只能用一个
用了QueryString,参数只能自己截了。
只能用一个
用了QueryString,参数只能自己截了。
解决方案 »
- java导出数据成excel 报错 求分析
- JSP中pageContext运用无法显示
- 一个通过JS方法来判断复选按钮是否选中的问题
- ibatis +mysql 有时乱码的问题
- 想学servlet,不知从哪里下手。高手给点建议
- jsp的url重写问题
- javabean编译问题
- 关于一段连接池的疑惑,谢谢大家了
- 请问这是为什么?java.sql.SQLException: No suitable driver
- "0xE7B3BBE7BB9FE7AEA1E79086E59198",用JSP分页程序写出来的,高手请教!!!!!!
- 急!!! 如何一次提交多条记录(字段是动态的)?????
- 怎样才能在当前页面新开一个窗口显示帮助文件的内容?
--------------------------------------------------------------------------------getInputStream
public ServletInputStream getInputStream()
throws java.io.IOExceptionRetrieves the body of the request as binary data using a ServletInputStream. Either this method or getReader() may be called to read the body, not both.
Returns:
a ServletInputStream object containing the body of the request
Throws:
java.lang.IllegalStateException - if the getReader() method has already been called for this request
java.io.IOException - if an input or output exception occurred--------------------------------------------------------------------------------getReader
public java.io.BufferedReader getReader()
throws java.io.IOExceptionRetrieves the body of the request as character data using a BufferedReader. The reader translates the character data according to the character encoding used on the body. Either this method or getInputStream() may be called to read the body, not both.
Returns:
a BufferedReader containing the body of the request
Throws:
java.io.UnsupportedEncodingException - if the character set encoding used is not supported and the text cannot be decoded
java.lang.IllegalStateException - if getInputStream() method has been called on this request
java.io.IOException - if an input or output exception occurred
See Also:
getInputStream()
FORM的提交方法决定servlet的接收方法
1、先调用getParameterNames(),得到所有的参数名称,再依次调用getParameterValues(Name)得到与名称对应的参数值,最后手工组合出完整的QueryString。只要参数名字的次序对了,得到的结果就和调用getQueryString()得到的相同,这样也不会影响到后续getParameter()的正常调用;
2、调用Request的getReader()函数,直接得到完整的QueryString。然后用得到的QueryString构造一个HttpServletRequestWraper对象,实现HttpServletRequest接口,模拟HttpServletRequest接口中所有函数的行为。这样的一个对象,就可以完全取代doPost()中作为参数传入的request了。我参考了Sun的原代码实现了HttpServletRequestWraper类,初步测试没有问题,但是实在没有把握在所有的环境中都没有问题。哪位还有没有更好的解决方法?
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;public class myRedirect
{
public static String dealurl(HttpServletRequest request)
{
String url = "";
url = request.getRequestURL()+"?";
Enumeration param = request.getParameterNames();
while(param.hasMoreElements())
{
String pname = param.nextElement().toString();
url += pname+"="+request.getParameter(pname)+"&";
}
if(url.lastIndexOf("&")==url.length()-1)
{
url = url.substring(0,url.lastIndexOf("&"));
}
if(url.indexOf("&")>-1)
url=url.replaceAll("&","@#@");
return url;
}
public static String geturl(String url)
{
if(url.indexOf("@#@")>-1)
url=url.replaceAll("@#@","&");
//url = "http://mms.nettoo.com.cn"+url.substring(url.indexOf("/mov"));
return url;
}
}比较好 同时支持get和post
需要参数排序?
还有什么情况下需要name对应多个value?