首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

下面程序为什么GET可以POST就不可以?该如何解决

2012-01-01 
下面程序为什么GET可以POST就不可以?下面这个程序有点怪,如果表单是这样的formenctype multipart/form-

下面程序为什么GET可以POST就不可以?
下面这个程序有点怪,   如果表单是这样的
<form   enctype= "multipart/form-data "   action= "submit.jsp "     method= "post "   name= "form1 ">
request收到的值全是NULL
而当改成
<form   enctype= "multipart/form-data "   action= "submit.jsp "     method= "get "   name= "form1 ">
时,   就能正确收到request值
这是为什么呢?


<%@   page   contentType= "text/html;   charset=gb2312 "   %>
<%@   page   language= "java "   import= "com.fredck.FCKeditor.* "   %>
<%@   page   import= "com.oa2007.tool.* "%>
<link   rel= "stylesheet "   type= "text/css "   href= "../../../../theme/1/style.css ">

<script   language= "javascript ">
function   highlight(obj){
var   hightlightBgColor   =   '#d6d6d6 ';
obj.onmouseover   =   function(){
var   o   =   event.srcElement;

if(o.tagName== "TD "){
with(o.parentElement){
style.backgroundColor   =   hightlightBgColor;
}
}
}

obj.onmouseout   =   function(){
var   o   =   event.srcElement;
if(o.tagName== "TD "){o.parentElement.style.backgroundColor   =   ' ';}
}
}

</script>


<html>
<head>
<title> 发布新闻 </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">

<script   Language= "JavaScript ">
function   CheckForm()
{
      if(document.form1.SUBJECT.value== " ")
      {   alert( "新闻的标题不能为空! ");
          return   (false);
      }


      return   (true);
}

function   sendForm()
{

    if(CheckForm())
      document.form1.submit();
}


</script>
</head>

<body   class= "bodycolor "   topmargin= "5 ">
<form   enctype= "multipart/form-data "   action= "submit.jsp "     method= "post "   name= "form1 ">
<table   border= "0 "   width= "100% "   cellspacing= "1 "   cellpadding= "0 "   class= "small ">
    <tr   class= "tablehead1 ">
        <td> <img   src= "../../../../images/notify_new.gif "   align= "absmiddle ">   新建新闻
        </td>
    </tr>
    <tr   class= "tablehead2 ">
    <td>
    <a   href= "# "   onclick= "sendForm(); "> <img   src= "../../../../images/button/issue.gif "   border= "0 "   title= "发布 "> </a>
    <a   href= "# "   onclick= "javascript:EDIT_HTML.location.reload() "> <img   src= "../../../../images/button/reset.gif "   border= "0 "   title= "重填 "> </a>
    <a   href= "# "   onClick= "location= '../ ' "> <img   src= "../../../../images/button/return.gif "   border= "0 "   title= "返回 "> </a>


   
    </td>
</table>
<br>
<table   border= "0 "   width= "100% "   cellpadding= "5 "   cellspacing= "1 "   align= "center "   class= "small ">
   
        <tr>
            <td   nowrap   class= "TableLine2 ">   标题: </td>
            <td   class= "TableLine1 ">  
                <input   type= "text "   name= "SUBJECT "   size= "40 "   maxlength= "40 "   class= "BigInput "   value= " ">
            </td>
        </tr>

        <tr>
            <td   class= "TableLine2 "   colspan= "2 ">
                  <%
String   text= " ";
FCKeditor   oFCKeditor   ;
oFCKeditor   =   new   FCKeditor(   request,   "EditorDefault "   )   ;
oFCKeditor.setBasePath(   "/oa2007/FCKeditor/ "   )   ;
oFCKeditor.setValue( "input ");
oFCKeditor.setValue(   Convert.toSpaceStr(text)   );
out.println(   oFCKeditor.create()   )   ;
%>
            </td>
        </tr>
            </table>
</form>

</body>
</html>

[解决办法]
如果我没记错的话,post和get方法的区别是处理少量数据和大量数据的,你再查查看,呵呵,怕误导你!
[解决办法]
enctype= "multipart/form-data " 这种方式 REQUEST不能直接用GETPARAMETER获得变量。

热点排行