⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 737_4.asp.htm

📁 实战留言簿(EJB+Struts+weblogic应用),主要是实现留言簿的全过程
💻 HTM
📖 第 1 页 / 共 4 页
字号:
import java.util.*;
import java.text.*;
import javax.rmi.PortableRemoteObject;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
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.ActionServlet;
import org.apache.struts.util.MessageResources;
import guestbook.maxuan.action.PAction;
import guestbook.maxuan.ejb.entity.value.*;
import guestbook.maxuan.ejb.entity.*;
import guestbook.maxuan.ejb.control.*;
import java.sql.*;

public final class LySaveAction  extends PAction{
  public ActionForward execute(ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response)
      throws Exception {
    Locale locale = getLocale(request);
    MessageResources messages = getResources(request);
    HttpSession session = request.getSession();
    BookValue value=null;
    LyForm lyForm = (LyForm) form;
    Context ctx = (Context)session.getAttribute("ctx");
    //errors.clear();
    if(control==null){
     control=getInitControl();
     session.setAttribute("control",control);
    }
    //errors = lyForm.check();

    try {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置留言时间格式
    String datestr = formatter.format(new Timestamp(cal.getTime().getTime()));
      value = lyForm.getValue();
      value.setIp(request.getRemoteAddr());//写入访问者IP
      value.setPosttime(datestr);
      control.savely(value);
    }catch(Exception e){
      e.printStackTrace();
    }
    return (mapping.findForward("success"));
  }
}</textarea><br>[Ctrl+A 全部选择 然后拷贝]</p>
<p>  在上面,我将原本写在里面的检查语句都注释掉了,大家可以自己写进去,也就是对邮件,留言不能为空等检查,当然也可以在页面中写javascript小脚本,不过这对有心恶意捣乱的人没什么用!<br>  PAction.java完成一些连接等初始动作,其它的分别为显示留言,提交留言等动作,也可以自行定义添加其它动作在里面!例如删除!<br>  好了,现在我们已经完成了EJB,利用Struts所写的JAVABEAN部分,接着我们需要完成JSP页面部分的编写! </p>

<p align="right">出处:<a href="http://www.blueidea.com/">蓝色理想</a>
<br>
责任编辑:<a href="http://www.blueidea.com/common/contact.asp?type=%B1%E0%BC%AD&amp;username=cjj" target="_blank">cjj</a></p>
<p align="right"><a title="上一页" href="http://www.blueidea.com/tech/program/2003/737_3.asp" style="font-size: 12px;">上一页 实战留言簿(EJB,Struts应用篇)[3]</a> <a title="下一页" href="http://www.blueidea.com/tech/program/2003/737_5.asp" style="font-size: 12px;">下一页 实战留言簿(EJB,Struts应用篇)[5]</a></p>
<p>◎进入论坛<a href="http://www.blueidea.com/bbs/list.asp?GroupName=Dreamweaver+MX+Developer+%D3%EB%CA%FD%BE%DD%BF%E2%B1%E0%B3%CC">网络编程</a>版块参加讨论
	     </p></td>
	   </tr>
	</tbody></table>
    </td>
    <td class="columnContent" align="center" valign="top" width="220"> 
<!--          <table width="100%" border="0" cellspacing="4" cellpadding="0">
              <tr> 
                <td align="center"><script language="JavaScript">showbanner(4,4);</script></td>
              </tr>
          </table>
 	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
	        <tr>
	          <td><img src="/img/spacer.gif" width="6" height="6"></td>
	        </tr>
	</table>
          <table width="100%" border="0" cellspacing="4" cellpadding="0">
              <tr> 
                <td align="center"><script language="JavaScript">showbanner(3,3);</script></td>
              </tr>
          </table>
 	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
	        <tr>
	          <td><img src="/img/spacer.gif" width="6" height="6"></td>
	        </tr>
	</table>
-->
	<table border="0" cellpadding="6" cellspacing="0" width="100%">
              <tbody><tr> 
                <td class="listTitle"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td><strong>相关文章</strong></td>
    <td align="right"><a href="http://www.blueidea.com/common/RelevantLinks.asp?documentid=737">更多相关链接</a></td>
    </tr></tbody></table></td>
              </tr>
              <tr> 
                <td class="listContent" valign="top">
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2006/3779.asp" target="_blank">XML+XSL+CSS+ASP打造留言簿</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2005/3019.asp" target="_blank">JavaBean与EJB有何不同之处</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2004/1603.asp" target="_blank">[J2EE] 实战开发EJB</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2003/911.asp" target="_blank">[J2EE]实战留言本(升级应用篇)</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2003/723.asp" target="_blank">[Asp]教你制作简单的留言簿</a><br>
                </td>
              </tr>
            </tbody></table>
 	<table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
	        <tbody><tr>
	          <td><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
	        </tr>
	</tbody></table>
	<table border="0" cellpadding="6" cellspacing="0" width="100%">
              <tbody><tr> 
                <td class="listTitle"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td><strong>作者文章</strong></td>
    </tr></tbody></table></td>
              </tr>
              <tr> 
                <td class="listContent" valign="top">
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2004/1603.asp">[J2EE] 实战开发EJB</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2003/911.asp">[J2EE]实战留言本(升级应用篇)</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2003/318.asp">IIS6“_PATH_”问题解决小技巧</a><br>
<img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/tech/program/2003/49.asp">实战 J2EE 开发购物网站 经验篇</a><br>
                </td>
              </tr>
            </tbody></table>
 	<table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
	        <tbody><tr>
	          <td><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
	        </tr>
	</tbody></table>

<form name="search" action="http://search.blueidea.com" method="get" style="margin: 0px; padding: 0px;" onsubmit="if(this.tr[1].checked &amp;&amp; this.searchby.value=='as_author')this.q.value='Author:\'' + this.q.value +'\'';">
<input name="domains" value="blueidea.com" type="hidden">
<input name="client" value="pub-5841412030047197" type="hidden">
<input name="forid" value="1" type="hidden">
<input name="channel" value="6876763258" type="hidden">
<input name="ie" value="GB2312" type="hidden">
<input name="oe" value="GB2312" type="hidden">
<input name="cof" value="GALT:008000;GL:1;DIV:336699;VLC:551A8B;AH:left;BGC:F2F3F7;LBGC:#8C8EA3;ALC:0000CC;LC:CC0033;T:000000;GFNT:#7777CC;GIMP:cc0033;LH:50;LW:778;L:http://www.blueidea.com/img/google_search_title.gif;S:http://www.blueidea.com;FORID:1;" type="hidden">
<input name="hl" value="zh-CN" type="hidden">
<table border="0" cellpadding="6" cellspacing="0" width="100%">
  <tbody><tr> 
    <td class="columnTitle"> <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr> 
          <td><a href="http://www.google.com/" target="_blank"><img src="737_4.asp_files/google_logo.gif" border="0"></a></td><td align="right"><input id="googleRadio" name="tr" value="" onclick="this.form.action='http://www.google.com/custom';form.searchby.style.display='none';document.getElementById('keyword').style.width='132px';" type="radio"><label for="googleRadio">全网</label>
		   <input name="tr" id="siteRadio" value="site" checked="checked" onclick="this.form.action='http://search.blueidea.com';form.searchby.style.display='';document.getElementById('keyword').style.width='70px';" type="radio"><label for="siteRadio">本站</label>
		    <input name="tr" id="bbsRadio" value="bbs" onclick="this.form.action='http://search.blueidea.com';form.searchby.style.display='none';document.getElementById('keyword').style.width='132px';" type="radio"><label for="bbsRadio">论坛</label></td>
        </tr>
      </tbody></table></td>
  </tr>
</tbody></table>

    <table class="columnContent" border="0" cellpadding="0" cellspacing="6" width="100%">
    <tbody><tr> 
      <td> <input id="keyword" name="q" size="10" value="" style="width: 70px;" type="text"> 
      </td>
      <td> <select name="searchby">
          <option value="content">内容</option>
          <option value="as_author">作者</option>
		   </select>
 </td>
      <td><input name="submit2" src="737_4.asp_files/searchbutton.gif" border="0" type="image" width="46" height="19"> 
        </td>
    </tr>
<!--    <tr> 
      <td><a href=/common/searchbykey.asp>关键字搜索</a></td>
      <td><a href="http://search.blueidea.com">常规搜索</a></td>
      <td><a href="/common/commend.asp">推荐文档</a></td>
    </tr>-->
    <tr> 
      <td colspan="3" class="list">热门搜索:<a href="http://www.blueidea.com/common/searchbykey.asp?keyword=css">CSS</a> <a href="http://www.blueidea.com/common/searchbykey.asp?keyword=fireworks">Fireworks</a> <a href="http://www.blueidea.com/news/game/">设计比赛</a> <a href="http://www.blueidea.com/tech/web/">网页制作</a> <a href="http://www.blueidea.com/common/searchbykey.asp?keyword=Dreamweaver">Dreamweaver</a> <a href="http://www.blueidea.com/common/searchbykey.asp?keyword=2006"><font color="red">Studio8</font></a>
        <a href="http://www.blueidea.com/common/searchbykey.asp?keyword=flash">Flash</a></td>
    </tr>
</tbody></table>
</form>
 	<table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
	        <tbody><tr>
	          <td><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>
	        </tr>
	</tbody></table>
<table class="listcontent" border="0" cellpadding="6" cellspacing="0" width="100%"><tbody><tr><td class="listTitle">
    <table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td><strong>站点最新</strong></td>
    <td align="right"><a href="http://www.blueidea.com/common/search1.asp?action=updatelist">站点最新列表</a></td>
    </tr></tbody></table></td></tr><tr><td valign="top"><table border="0" cellpadding="2" cellspacing="0" width="100%">
    <tbody><tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6186.asp">疯狂的程序员 第五十回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6185.asp">疯狂的程序员 第四十九回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6184.asp">疯狂的程序员 第四十八回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6183.asp">疯狂的程序员 第四十七回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6182.asp">疯狂的程序员 第四十六回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6181.asp">疯狂的程序员 第四十五回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6180.asp">疯狂的程序员 第四十四回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6179.asp">疯狂的程序员 第四十三回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6178.asp">疯狂的程序员 第四十二回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    <tr><td><img src="737_4.asp_files/arrow.gif" width="4" height="13"> <a href="http://www.blueidea.com/column/member/2008/6177.asp">疯狂的程序员 第四十一回</a></td></tr><tr><td colspan="2" class="dotLine"></td></tr>
    </tbody></table></td></tr></tbody></table>

	<table class="border" border="0" cellpadding="0" cellspacing="0" width="100%">
	        <tbody><tr>
	          <td><img src="737_4.asp_files/spacer.gif" width="6" height="6"></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -