首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

struts1.2 有关问题! 插入以后"她"没反应啊

2012-01-24 
struts1.2问题! 插入以后"她"没反应啊!//CreatedbyMyEclipseStruts//XSLsource(default):platform:/plugin

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 ");
}
//   如果没有错误生成,成功插入了数据,则生成ActionMessage对象
//   以封装一条确认信息,并将其包含入ActionMessages对象中
actionMessages.add( "insertzhuceSucceed ",   new   ActionMessage(
"zhuce.insert.succeed "));


//   将ActionMessages对象保存到request范围内
saveMessages(request,   actionMessages);
//   指定转发的页面
return   (mapping.findForward( "InsertzhuceSucceed "));
}}
-------------------------------
数据能查如数据库 但是跳转到show.jsp页面没的反映!

________________________________

下面是struts-config.xml
<?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>
    <data-sources   />
    <form-beans   >
        <form-bean   name= "zhuceForm "   type= "com.zqswork.struts.form.ZhuceForm "   />

    </form-beans>

    <global-exceptions   />
    <global-forwards   />
    <action-mappings   >
        <action
            attribute= "zhuceForm "
            input= "/zhuce.jsp "
            name= "zhuceForm "
            path= "/zhuce "
            type= "com.zqswork.struts.action.ZhuceAction ">
            <forward
                name= "InsertzhuceFailed "
                path= "/show.jsp "
                redirect= "true "   />
                <forward
                name= "insertzhuceSucceed "
                path= "/show.jsp "
                  />
        </action>

    </action-mappings>

    <message-resources   parameter= "com.zqswork.struts.ApplicationResources "   />
</struts-config>


资源文件已经配置  

show.jsp里有这样的内容 <body>
   
    <center>
<%--logic:messagesPresent标签进行输出条件判断,当由属性指定的--%>
<%--ActionMessages对象、ActionErrors对象、String对象或者String数组对象--%>
<%--包含于请求作用域时,则对标签体内容输出,否则不输出任何内容--%>
<%--message属性值为true的时候从request作用域中获取用于迭代的消息,--%>
<%--在该情况下,name属性的设置值被忽略--%>
<logic:messagesPresent   message= "true ">
<%--html:messages标签的处理类每次从消息集合中取出一个ActionMessage--%>
<%--对象,把它命名为“message”,bean:write标签接着把这个名为--%>
<%--“message”的ActionMessage对象的消息输出到页面--%>
<%--id属性用来命名从消息集合中检索出的每个ActionMessage--%>
<%--对象,它和bean:write标签的name属性匹配--%>
<%--message属性指定消息的来源,如果为true,则从request或session范围内检索出--%>
<%--属性key为Globals.MESSAGE_KEY对象,此时name属性无效--%>
<html:messages   id= "message "   message= "true ">
<%--bean:write标签获取并输出bean的属性值--%>
<bean:write   name= "message "   />
</html:messages>
</logic:messagesPresent>



<br>
    --------------------



[解决办法]

[解决办法]
你的太小了,所以没反应

热点排行