Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
s:表单提交后,表单溢出到下一个jsp_Jsp_Jquery Mobile_Struts2 - Fatal编程技术网

s:表单提交后,表单溢出到下一个jsp

s:表单提交后,表单溢出到下一个jsp,jsp,jquery-mobile,struts2,Jsp,Jquery Mobile,Struts2,我在第一个jsp中有一个标记,当我通过struts操作提交表单并显示另一个jsp时,表单标记似乎也扩展到了第二个jsp。(如firebug中所观察到的)。我在这些JSP中有一些id相同的元素,用这种方式将它们组合在一起会给我带来很多问题。另外,第二个jsp的部分被忽略 这是page1.jsp的基本结构: <html> <head> <%@ taglib uri="/struts-tags" prefix="s" %> <script t

我在第一个jsp中有一个
标记,当我通过struts操作提交表单并显示另一个jsp时,表单标记似乎也扩展到了第二个jsp。(如firebug中所观察到的)。我在这些JSP中有一些id相同的元素,用这种方式将它们组合在一起会给我带来很多问题。另外,第二个jsp的
部分被忽略

这是page1.jsp的基本结构:

<html>
<head>
    <%@ taglib uri="/struts-tags" prefix="s" %> 
    <script type="text/javascript" src="../js/page1.js"></script>
</head>
<body>
    <s:form name="form1" id="form1" action="" method="post" namespace="">
        <div data-role="page" id="firstPage">
            <div id="xyz" class = "xyz"></div>
            .....//other elements
        </div>
    </s:form>
    <script type="text/javascript">
        .... // do stuff and submit "form1" to process.action
    </script>
</body>
</html>
ProcessAction.java:

public class ProcessAction{
    private String xyz;

    //other elements
    //getters and setters

    @Override
    public String process() {
       //get data from DB and set it to xyz and other elements, 
       //whose corresponding elements are in page2.jsp

       return SUCCESS;
    }
}

不确定这是否与您的错误有关,但这肯定是一个错误:
必须放在任何HTML语句之前,甚至放在DTD之前,而不是放在
标记内


您也应该使用
元素的
action
属性,而不是将其设置为空,然后(我猜)通过javascript设置它。您需要在描述中更加明确:如果您提交了表单,并且该操作正在触发,则它是一个新请求,并且第一页已经消失。你要么没有告诉我们关于JavaScript的事情,要么你的主题,或者。。。?如果您使用默认主题,您的HTML将无效,当然,您不能在表行周围放置任意div。。。我仍然有同样的问题。你能发布你的Struts.xml和你行动的相关部分吗?这是我添加的struts.xml和action。而且,提神也很有效。虽然重新加载时不存在填充页面所需的数据,但重新加载时,此特定问题会消失。
<html>
<head>
    <%@ taglib uri="/struts-tags" prefix="s" %> 
    <script type="text/javascript" src="../js/page1.js"></script>
</head>
<body>
  <form name="form1" id="form1" method="post" action="process.action">
      <div data-role="page" id="firstPage">
          <div id="xyz" class = "xyz"></div>
          .....//other elements
      </div>
      <div data-role="page" data-external-page="true" id="secondPage">
          <div id="xyz" class = "xyz"></div>
          .....//other elements
      </div>
  <form>
  <script type="text/javascript">
      .... // do stuff and submit "form1" to process.action
  </script>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="location" namespace="/location">
        <action name="start" class="StartAction">
            <result name="success">/WEB-INF/templates/location/page1.jsp</result>
        </action>

        <action name="process" class="ProcessAction">
            <result name="success">/WEB-INF/templates/location/page2.jsp</result>
        </action>

    </package>
</struts>
public class ProcessAction{
    private String xyz;

    //other elements
    //getters and setters

    @Override
    public String process() {
       //get data from DB and set it to xyz and other elements, 
       //whose corresponding elements are in page2.jsp

       return SUCCESS;
    }
}