taitoushan
2009-08-14 13:23
浏览 324
已采纳

struts中action怎么都没执行的奇怪问题

我点击了按钮之后就是啥反应都没有,后台也不报错

<%@ include file="/common/taglibs.jsp"%>
<%@ page pageEncoding="GBK"%>

<html>
<head>
<title>工作动态添加</title>
<script type="text/javascript">
function sure(){
alert("表单提交");
contentForm.submit;
}
</script>

</head>

<body bgcolor="#d9e7f8" onload="load()">
<html:form action="/edit/addnew.do?method=save" method="post">
<table width="87%" border="0" align="left">
  <tr>
    <td colspan="2" align="center">
    <b><div id="biaotou" style="font-size: 15px"></div></b></td>
  </tr>
  <tr>
    <td width="7%" height="35" style="font-size: 12px" align="right">标题:</td>
    <td width="93%">
<input type="text" id="title" name="title" size="60"/> </td>
  </tr>
  <tr>
    <td width="7%" height="35" style="font-size: 12px" align="right">来源:</td>
    <td width="93%">
<input type="text" id="source" name="source" size="60"/> </td>
  </tr>
  <tr>
    <td height="51" valign="top" style="font-size: 12px" align="right">内容:</td>
    <td><input type="hidden" name="content" id="content"/>
<iframe id="myiframe" src="editor/editor.htm?id=content&ReadCookie=0" frameborder="0" scrolling="no" width="621" height="457"></iframe>
    </td>
  </tr>
  <tr>
    <td height="51">&nbsp;</td>
    <td align="center">
   <html:button property="sure1" onclick="sure();" id="baocun" >保存</html:button>
<input type="button" value="取消"  onclick="sure();"/> </td>
  </tr>
</table>
  </html:form>
</body>
</html>
----------------------------
配置文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <form-beans>
   <form-bean name="contentForm" type="com.jtpsoft.webapp.form.xtgl.ContentForm"/>
  </form-beans>

  <action-mappings>
 
<action path="/edit/addnew" parameter="method" input="/edit/addNew.jsp"
name="contentForm" type="com.jtpsoft.webapp.action.xtgl.ContentAction"
scope="request" unknown="false" validate="false">
<forward name="list" path="/edit/gzdt.jsp"></forward>
</action>

  </action-mappings>

</struts-config>

------------------------
对应的action


public class ContentAction extends BaseAction {
//录入数据
public ActionForward save(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
{
System.out.println("执行action");
}


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • tobackfurture 2009-08-20 17:58
    已采纳

    很明显,你的这个javascript的代码写错了!到csdn上下点别人的代码看看!就知道了,也可以多学点东西.

    打赏 评论

相关推荐 更多相似问题