页面代码<html:form  action="tree.do?operate=doOrderTree" method="post">
<input type="button" value="调用js" onclick="sendUrl()"/>
<input type="submit" value="提交" />
</html:form>
以下是调用的jsfunction sendUrl()
{
document.forms[0].action="tree.do?operate=doOrderTree";
document.forms[0].submit();
}用第二个按钮直接提交表单可以正常到达我想要的action 但是第一个按钮调用同样action却是404各位高手麻烦帮我看下啊

解决方案 »

  1.   

    document.forms[0].submit(); 
    这句什么意思
      

  2.   

    404错误是没找到资源的意思,你可以右键--属性,看一下url是多少,应该是少了层项目名吧document.forms[0].action="<%=request.getContextPath()%>/tree.do?operate=doOrderTree"; 
      

  3.   

    可以给表单name添加名称:name=form1
    然后JS代码中直接:document.form1.submit();因为你的action
    应该定义了路径,这样应该可以实现!
      

  4.   

    你先把404页面提交的url找出来,看看是不是哪里错了。
    function sendUrl() 

    document.forms[0].action="tree.do?operate=doOrderTree"; 
    alert(document.forms[0].action);
    document.forms[0].submit(); 

    我怀疑是路径错了,如果不行,就在js中的action中加项目名称。
    document.forms[0].action="xxx/tree.do?operate=doOrderTree"; 
      

  5.   

    JS也没有写错...只是路径错了...form表单设置的action是相对路径
    JS中需要写绝对路径....
      

  6.   

    document.forms[0].action=" <%=request.getContextPath()%>/tree.do?operate=doOrderTree"; 
    因为<html:form  action="tree.do?operate=doOrderTree" method="post"> 可以自动查找项目名
      

  7.   

    试试tree前面加个/,按理说3楼应该可以的。function sendUrl() 

    document.forms[0].action="/tree.do?operate=doOrderTree"; 
    document.forms[0].submit(); 

      

  8.   

    document.forms[0].action="<%=request.getContextPath()%>/tree.do?operate=doOrderTree"; 
    or
    先从Action 跳到这个页面,再进行提交,这样应该是可以的啦。