错误原因如下
我在前台用的method是get
在后台servlet中是doGet方法调用的doPost方法
在doPost方法中可以接收到前台传来的值
可是
我在前台换成method是get后
在后台servlet中还是doGet方法调用的doPost方法
在doPost方法中就接收不到前台传来的值了
怎么回事啊 按理说 应该是后一种方法能接收到啊~~~
急切恳求答复~

解决方案 »

  1.   

    错了 下面可是后面的method是post
    不好意思
      

  2.   

    你的doPost()是不是protected
    doGet()是public
      

  3.   

    给点代码看看,按理来说,应该是post方法可以接到的!
      

  4.   

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    // 上传图片
    String ext = "";
    String filename = "";
    boolean uploadSucc = true;
    int MAX_FILE_SIZE = 1000000;
    int TOTAL_MAX_FILE_SIZE = 4000000;
    String ALLOWED_FILE_TYPE = "jpg,gif,JPG,GIF";
    SmartUpload su = new SmartUpload();
    try {
    su.initialize(this.getServletConfig(), request, response);
    su.setMaxFileSize(MAX_FILE_SIZE);
    su.setTotalMaxFileSize(TOTAL_MAX_FILE_SIZE);
    su.setAllowedFilesList(ALLOWED_FILE_TYPE);
    su.upload();
    } catch (Exception e) {
    log.writeTxtLog("LinkinfoServlet-doPost:", "upload"
    + e.getMessage() + "Fail");
    }
    String filePath = this.getServletConfig().getServletContext()
    .getRealPath("/");
    try {
    com.jspsmart.upload.File file = su.getFiles().getFile(0);
    ext = file.getFileExt();
    Calendar calendar = Calendar.getInstance();
    filename = String.valueOf(calendar.getTimeInMillis());
    filename = filename + "." + ext;
    file.saveAs(filePath + "link\\linkinfo\\upload\\" + filename,
    SmartUpload.SAVE_PHYSICAL);
    } catch (Exception e) {
    log.writeTxtLog("LinkinfoServlet-doPost:", "upload Fail");
    filename = "";
    }

    // 获取操作类型
    int oper = weboper.getParameterFromHttpServletRequest(request,
    RequestConst.REQUEST_OPERATE, -1);

    // 获取页面返回地址
    String backurl = weboper.getParameterFromHttpServletRequest(request,
    RequestConst.REQUEST_BACKURL);
    String result = "";
    String strIP = request.getRemoteHost();
    String strUserName = weboper.getParameterFromHttpSession(request
    .getSession(), SessionConst.SESSION_USER_LOGINNAME);
    前台页面用的post方法 这样接收不到oper的值 前台传得是隐藏表单域