struts1.2 问题! 插入以后"她"没反应啊!
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.1/xslt/JavaClass.xsl
package com.zqswork.struts.action;
import
java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.
ActionMessages;
import com.zqswork.struts.form.ZhuceForm;
import com.zqswork.struts.model.zhuceBean;
/**
* MyEclipse Struts
* Creation date: 05-10-2007
*
* XDoclet definition:
* @struts.action path= "/zhuce " name= "zhuceForm " input= "/zhuce.jsp " scope= "request " validate= "true "
*/
public class ZhuceAction extends Action {
// --------------------- Instance Variables
// --------------------- Methods
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
String username = null;
String password;
ActionMessages actionMessages = new ActionMessages();
//Java在网络传输中使用的编码是 "ISO-8859-1 ",从网页中读取中文时需要进行转化
username = ((ZhuceForm) form).getUsername();
username = new String(username.getBytes( "ISO-8859-1 "), "GB2312 ");
password = ((ZhuceForm) form).getPassword();
password = new String(password.getBytes( "ISO-8859-1 "), "GB2312 ");
try {
// 由得到的标题title及内容content,生成NoticeBean
zhuceBean bean = new zhuceBean(username, password);
// 将NoticeBean持久化到数据库中
bean.insert();
} catch (Exception ex) {
ex.printStackTrace(System.out);
// 如果插入数据失败,则生成ActionMessage对象以封装错误提示信息
// 并将其包含入ActionMessages对象中
actionMessages.add( "InsertzhuceFailed ", new ActionMessage(
"zhuce.insert.failed "));
// 将ActionMessages对象保存到request范围内
saveMessages(request, actionMessages);
// 指定转发的页面
return mapping.findForward( "InsertzhuceFailed ");
}
//