*Java EE 项目案例

本文介绍了一个基于JavaEE的项目集合,涵盖了从简单的Servlet应用到复杂的Spring框架应用等多个案例。涉及的技术包括Java、Spring、Hibernate、Struts及数据库连接等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Java EE 项目案例
运行环境
Tomcat  5.5,MySQL  5.0.45
Eclipse SDK  3.2
Spring 2.0
Hibernate 3.0

现有项目到工作空间中导入下面几个项目
数据库目录复制到“mysql安装根目录“

Buy演示购物:  Java+JavaBeans ^     

第2章的示例程序。
Lab:科研 新闻发布  ^ servlet取代action之前;自建标签   

 第3章的示例程序。
NoticeManager: ^   第4章的示例程序。
BBS:      第5章的示例程序。
BookStore: ^    第6章的示例程序。
Individuation: ^ Ajax+spring  第7章的示例程序。
MyStuMan: ^ (数据库在hibernate的配置错误,不会出现

Servlet action is not available) hiber+struts+log4j   

第8章的示例程序。
FileManager: ^(数据库连接在struts中配置错误,会出现servlet action is

available的提示)   第9章的示例程序。
OrderTickets: 文件找不到404错误,怎么回事   第10章的示例程序。


-1
<jsp:useBean id="selectaddcoinBean"
 class="com.buy.bean.coin.AddcoinSelectBean" scope="request">
</jsp:useBean>
<jsp:setProperty name="selectaddcoinBean" property="s_year"
 param="s_year" />  文本框的字段名字是"s_year"
这样设置的好处,就是不用在用request来取文本框的值   
—2
action="<%=basePath%>/add_teacher"

<jsp-config>
  <taglib>
  <taglib-uri>control</taglib-uri>
  <taglib-location>/WEB-INF/mytag.tld</taglib-location>
 </taglib>
<%@ taglib uri="control" prefix="control"%>
<control:news4news />


-3
Servlet action is not available (十有八九是配置文件错误)
Action连接数据库出问题会报这种错误(driverClassName,url,用户密码,驱动

包等原因)Action中使用noticemanagerDB来连接数据库
 <data-sources>
  <data-source key="noticemanagerDB"
   

type="org.apache.commons.dbcp.BasicDataSource">
   <set-property property="driverClassName"
    value="com.mysql.jdbc.Driver" />
   <set-property property="url"
    

value="jdbc:mysql://localhost:3307/noticemanager" />
   <set-property property="username"

value="root" />
   <set-property property="password"

value="root" />
  </data-source>
 </data-sources>
要先测试一下
try {
   String name = "com.mysql.jdbc.Driver";
   String url =

"jdbc:mysql://localhost:3307/noticemanager?                                            

         useUnicode=true&characterEncoding=gb2312";
   Class.forName(name).newInstance();
   Connection con =

DriverManager.getConnection(url, "root", "root");
   System.out.println("连接MySQL 5.0.18成功!(驱

动3.1.8)");
   PreparedStatement pStmt = null;
   ResultSet rs = null;
   int id = 0;
   String title = null;
   String content = null;
   String strSql = new String("SELECT * FROM

notice");
   try {
    pStmt = con.prepareStatement(strSql,
      

ResultSet.TYPE_SCROLL_INSENSITIVE,
      

ResultSet.CONCUR_READ_ONLY);
    rs = pStmt.executeQuery();
    if(rs.next()) {
     id = Integer.parseInt

(rs.getString("ID"));
     title = rs.getString("Title");
     title = new String

(title.getBytes("ISO-8859-1"), "GB2312");
     content = rs.getString

("Content");
     content = new String

(content.getBytes("ISO-8859-1"), "GB2312");
     System.out.println(id);
     System.out.println(title);
     System.out.println(content);
    }
   } finally {
    try {
     rs.close();
     pStmt.close();
     con.close();
    } catch (Exception e) {
     e.printStackTrace();
    }
   }

  } catch (Exception e) {
   e.printStackTrace();
  
}

*这章怎么连接数据库的哪,有多个地方?
DB db = new DB(DBUtil.connectToDB()); DBUtil中有设置数据名等。。

---4

 

————————————————————————————————————
  如果你的工作时间是固定的
SimpleDateFormat myFormat=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();

//当前日期后7天的日期
cal.add(Calendar.DATE, 7);

 

运行环境 操作系统:Windows XP。 Java平台:JDK 1.5。 Web服务器:Tomcat v 5.5.23,下载地址:http://tomcat.apache.org/。 数据库服务器:MySQL v 5.0.45,下载地址:http://www.mysql.com/。 开发平台:Eclipse SDK v 3.2.2,下载地址:http://www.eclipse.org/download/index.jsp。 Eclipse插件TomcatPlugins v 3.2.1,下载地址:http://www.eclipse-plugins.info/eclipse/index.jsp。 Eclipse插件ResourceBundleEditor v 0.7.7,下载地址:http://resourcebundleeditor.com/。 Eclipse插件MyEclipse v 5.5.1,下载地址:http://www.myeclipseide.com/ Spring 采用 2.0 版本 Hibernate 采用3.0版本 ============================ 请注意:如出现中文乱码,检查如下配置是否正确。 (1)MySql 数据库是否是utf-8 格式(在安装时选择支持多语言),数据是否正常。 (2)项目是否为utf-8格式(同时看看的源代码文件中,中文是否乱码)。 (3)JSP页面是否是utf-8 格式。 (4)在web.xml 是否配置了编码过滤器。 (5)数据源配置的url(?useUnicode=true&characterEncoding=UTF-8),具体请看项目实例。 如果上面5步都没问题,你就不存在中文乱码问题。 ============================== 数据库使用的是MySQL,其版本为5.0.45 版本。 数据库的用户名及密码均为root。 使用的时候,请参考附件数据库导入一节。或将需要用到的某章的数据库目录复制到“mysql安装根目录\data”文件夹下就可以了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值