稀奇古怪的问题!关于request
我在一个类中声明一个HttpServletRequest request属性;
该类中包含setRequest(HttpServletRequest req){
this.request=req;
}
有个输出的方法 在里面用request.getParameter( "属性名 ")获得到的值是NULL
但是在setRequest中使用req.getParameter( "属性名 ")就能获得到值;
PS:2个属性名完全一样
为什么会这样?
期待解答
我把代码帖出来 大家看看
这个是那个调用定时器任务的servlet
package myServlet;
import
java.io.IOException;
import java.io.PrintWriter;
import java.util.Timer;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import myClass.myTimerTask;
public class ActionServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public ActionServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy " string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws
ServletException if an error occurred
* @throws
IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String url=request.getParameter( "url ");
String fid=request.getParameter( "fid ");
String tid=request.getParameter( "tid ");
int interval=Integer.parseInt(request.getParameter( "interval "));
String content=request.getParameter( "content ");
String type=new String(request.getParameter( "type ").getBytes( "ISO-8859-1 "), "gbk ");
String forwardUrl=url+ "?step=2&action=reply&editor=0&atc_attachment=none&fid= "+fid+ "&tid= "+tid+ "&atc_content= "+content+ " ";
Timer myTimer=new Timer(true);
if(type.equals( "开始 ")){
myTimerTask test=new myTimerTask();
test.setRequest(request);
myTimer.schedule(test, 0, interval*1000);
}