当前位置: 代码迷 >> Java Web开发 >> (struts1.2)为什么点了添加按钮没执行Action?该怎么解决
  详细解决方案

(struts1.2)为什么点了添加按钮没执行Action?该怎么解决

热度:3091   发布时间:2013-02-25 21:21:43.0
(struts1.2)为什么点了添加按钮没执行Action?
jsp
? <body>
? <html:form action="addinstitution.do" method="post">
? <table bgcolor='limt' width='100%'>
<tr>
<td>
<FONT color='white' ><b>学生奖惩信息录入 </b></FONT>
</td>
</tr>
? </table>
? <br>
? <br>

? <tr>
? ?
? <td width="100%" >
<fieldset style="height:45%;width:80%">
<legend>奖惩信息</legend>
<br>
<table width="650" border="0" cellpadding="2" cellspacing="1" height="130">
<tr>
<td nowrap align="right" width="9%">奖惩名称:</td>
<td width="36%">
<input name="institution_name" type="text" class="input" id="institution_name"/>
<font color="red">*<html:errors property="institution_name"/></font></td>
? </tr>
<tr>
<td nowrap align="right" width="9%">学号:</td>
<td width="36%">
<input name="student_id" type="text" class="input" id="student_id"/>
<font color="red">*<html:errors property="student_id"/></font></td>
</tr>
<tr>
<td width="11%" nowrap align="right">奖惩说明:</td>
<td><textarea name="institution_content" cols="40" rows="6" class="input" id="institution_content"></textarea>
<font color="red">*<html:errors property="institution_content"/></font></td> ?
</tr>

</table>
</fieldset>
</td>
</tr> ?
? <br>
<table align="center" >
<tr>
<td colspan="3" align="center">
<html:submit value="添加" />?
? <html:reset value="重置" /></td>
</tr> ?
? </table> ?
? <br>?
? ?
? </html:form>
? <br>
? <center><font color=red><html:errors property="sucaddinstitution"/></font></center>
? <center><font color=red><html:errors property="loseaddinstitution"/></font></center>
? </body>



Action
String studentid=institutionForm.getStudent_id();
String institutionname=institutionForm.getInstitution_name();
String institutioncontent=institutionForm.getInstitution_content();

String pageFoword="";


try {

Connection conn=null;
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123");

String sql1="insert into b_institution(student_id,institution_name,institution_content,createtime) values(?,?,?,?)";

PreparedStatement ps=conn.prepareStatement(sql1);
ps.setString(1, studentid);
ps.setString(2, institutionname);
ps.setString(3, institutioncontent);

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String createtime = sdf.format(new Date());
ps.setString(4, createtime);
? ?
int count=ps.executeUpdate();

if(count!=0)
{
ActionMessages mgs=new ActionMessages();
mgs.add("sucaddinstitution", new ActionMessage("add.suc"));
  相关解决方案