日期:2014-05-18  浏览次数:20602 次

POST与GET-Struts
一个FORM

<FORM   action= "/maintain.do?operation=add "   method= "post "   >
    ...
</FORM>

然后试图在Action的execute中获取action   url   后的operation值:

String   op=request.getParameter( "operation ");

发现,如果定义Form时,method= "post ",则可以通过上面语句获得字符串 "add ",相反,如果定义form时,method= "get ",发现通过上述语句获取不到operation的值,op是null.

请问是何道理?

------解决方案--------------------
你说反了吧?应该是method= "get " 才能得到值。
要想post得到值 在form里面加一个 <input type=hidden name=operation value=add>
------解决方案--------------------
要用get就是把参数写入链接,
要用post就是用隐藏域传.