在两个页面内都有表单提交:
第一个页面的脚本代码:(form1是该页面中表单的name属性值)
//文档编辑
function edit()
{
this.form1.action="<%=request.getContextPath()%>/document/editDocument!editDocumentInfo.do?docId="+ $('docId').value;
this.form1.submit();
}
可以正确转向到对应的页面。
第二个页面的脚本代码:(Form1是该页面表单的name属性值)
function edit()
{
var chks=document.getElementsByName('ID');
var text="";
var value="";
var isHaveChk=0;
var checkCount=0;
for(var i=0;i<chks.length;i++){
var objchk=chks[i];
if(objchk.checked)
{
checkCount++;
}
}
if(checkCount>1){
alert('只能选择 1 条记录!');
return;
}
for(var i=0;i<chks.length;i++){
var objchk=chks[i];
if(objchk.checked)
{
value=objchk.getAttribute("value");
var url="<%=request.getContextPath()%>/document/editDocument!editDocumentInfo.do?docId="+ value;
// window.location.href = url;
this.Form1.action=url;
this.Form1.submit();
}
}
if(value=="")
{
alert('请选择记录!');
}
}
可是运行后控制台报出:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception No result defined for action com.miracle.dm.doc.document.action.DocumentAction and result input - action - file:/D:/Tomcat%206.0/webapps/DataManager/WEB-INF/classes/com/miracle/dm/doc/document/action/struts-doc.xml:17:86
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:345)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
...
但是把上面第二个页面中的
// window.location.href = url; 注释取消,把下面两句注释掉
this.Form1.action=url;
this.Form1.submit();
即:
window.location.href = url;
//this.Form1.action=url;
//this.Form1.submit();
则可以正常转向到对应的页面。
请问这是什么原因,本来是正常的,但是版本同步后(我们是几个人一起开发)就出错了。
第一个页面的脚本代码:(form1是该页面中表单的name属性值)
//文档编辑
function edit()
{
this.form1.action="<%=request.getContextPath()%>/document/editDocument!editDocumentInfo.do?docId="+ $('docId').value;
this.form1.submit();
}
可以正确转向到对应的页面。
第二个页面的脚本代码:(Form1是该页面表单的name属性值)
function edit()
{
var chks=document.getElementsByName('ID');
var text="";
var value="";
var isHaveChk=0;
var checkCount=0;
for(var i=0;i<chks.length;i++){
var objchk=chks[i];
if(objchk.checked)
{
checkCount++;
}
}
if(checkCount>1){
alert('只能选择 1 条记录!');
return;
}
for(var i=0;i<chks.length;i++){
var objchk=chks[i];
if(objchk.checked)
{
value=objchk.getAttribute("value");
var url="<%=request.getContextPath()%>/document/editDocument!editDocumentInfo.do?docId="+ value;
// window.location.href = url;
this.Form1.action=url;
this.Form1.submit();
}
}
if(value=="")
{
alert('请选择记录!');
}
}
可是运行后控制台报出:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception No result defined for action com.miracle.dm.doc.document.action.DocumentAction and result input - action - file:/D:/Tomcat%206.0/webapps/DataManager/WEB-INF/classes/com/miracle/dm/doc/document/action/struts-doc.xml:17:86
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:345)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
...
但是把上面第二个页面中的
// window.location.href = url; 注释取消,把下面两句注释掉
this.Form1.action=url;
this.Form1.submit();
即:
window.location.href = url;
//this.Form1.action=url;
//this.Form1.submit();
则可以正常转向到对应的页面。
请问这是什么原因,本来是正常的,但是版本同步后(我们是几个人一起开发)就出错了。
解决方案 »
- 超异常的 weblogic 发布项目
- 求发一些javaweb项目。
- Servlet.service() for servlet jsp threw exception java.lang.NullPointerException
- SSH+ExtJS框架中Action往Extjs传参的问题!
- 请问环回地址是不是一定是127.0.0.1?
- 初学servlet,servlet到底该如何调用?我怎么调用不起来?
- jdk+Tomcat+Mysql无法配通?
- 为什么在JSP中往数据库中保存中文数据以后,表中的记录的中文部分总是NULL值
- 请JSP高手解答!如何解决?
- 在MyEclipse中整合struts遇到的问题
- 又一个乱码问题--求教
- 关于tomcat5.5的servlet调用器的开启问题
Action配置文件有问题,应该是你通过form提交时,Action类返回的的参数在配置文件里面没有定义。而不通过form直接跳转时,Action类返回的参数返回参数在配置文件里面有定义。
<include file="struts-default.xml" />
<package name="doc-document" extends="struts-default" namespace="/document">
<action name="editDocument" class = "documentAction" method="editDocumentInfo">
<result name="success">/apps/doc/document/DocumentEdit.jsp</result>
<result name="error">apps/doc/favorite/error.jsp</result>
</action>
action类的代码如下:
/**
* 进入修改新文档页面
* @return
*/
public String editDocumentInfo() {
if(null==this.getRequest().getParameter("docId")||"".equals(this.getRequest().getParameter("docId").trim())){
return this.ERROR;
}
long docId = Long.parseLong(this.getRequest().getParameter("docId"));
DocumentInfo documentInfo = docuInfoManager.getDocumentInfo(docId);
String docTempid;
List docAttchmentList = docuInfoManager.getDocAttchmentListByDocId(docId);
if(null!=docAttchmentList&&docAttchmentList.size()>0){
docTempid = ((DocAttachmentInfo)docAttchmentList.get(0)).getDocTempid();
}else{
docTempid = StringUtil.getUUID();
}
documentInfo.setDocTempid(docTempid);
DocCatalogInfo docCatalogInfo = docuInfoManager.getDocCatalogInfo(docId);
if(null!=docCatalogInfo){
ActionContext.getContext().put("docCatalogInfo", docCatalogInfo);
}
List roleList = new ArrayList();
List departmentList = new ArrayList();
List groupList = new ArrayList(); List docOwerList;
docOwerList=docuInfoManager.selectObjectIDOfdocOwnerBydocID(documentInfo.getDocId());
String strObjID="";
String strObjType="";
for (int i = 0; i < docOwerList.size(); i++){
DocOwnerInfo temp=(DocOwnerInfo)docOwerList.get(i);
strObjID=temp.getObjectId();
strObjType=temp.getObjectType();
if ("R".equals(strObjType)){
roleList.add(makeGroupRelation(strObjID));
}
else if ("D".equals(strObjType)){
departmentList.add(makeGroupRelation(strObjID));
}
else if ("G".equals(strObjType)){
groupList.add(makeGroupRelation(strObjID));
}
}
this.getRequest().setAttribute("role_list", roleList);
this.getRequest().setAttribute("department_list", departmentList);
this.getRequest().setAttribute("group_list", groupList);
ActionContext.getContext().put("documentInfo", documentInfo);
return this.SUCCESS;
}