Myeclipse 创建ssh框架

来源:互联网 发布:淘宝网店怎么赚钱 编辑:程序博客网 时间:2024/04/28 05:05

1、new一个web project。

image

2、右键项目,为项目添加Struts支持。

image

image

image

点击Finish。src目录下多了struts.xml配置文件。

image

3、使用MyEclipse DataBase Explorer建立数据源。

image

new一个数据源。填入数据源信息。

image

点击test Driver,如果成功显示:

image

点击OK,点击Finish。

4、为项目添加Spring支持。

image

选择五个包,之后JAR Library Installation为如下图。

image

点击Next。

image

默认点击Finish。

5、为项目添加Hibernate支持。

image

image

默认的包,更改JAR Library Installation。

点击Next。

image

选择是建立Hibernate自己的配置文件,还是合并到Spring的配置文件。选择合并,即更改点选框,点击Next。

image

选择Existing Spring Configration File,点击Next。

image

选择我们刚刚创建的数据源。点击Next。

image

去掉复选框的勾勾,点击Finish。

6、发布项目,此时已经可以访问这个项目的jsp页面了。

image

7、后续工作。

在web.xml里面加入spring配置与监听如下。

<context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/classes/applicationContext.xml </param-value>
  </context-param>
  <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

在applicationContext中的bean为sessionFactory添加属性

<!-- 设置控制台输出sql语句最大输出数为50 -->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">50</prop
>

在struts.xml中添加

    <constant name="struts.i18n.encoding" value="UTF-8" />
    <constant name="struts.custom.i18n.resources" value="cn.s2sh.action.token"></constant>
    <constant name="struts.objectFactory" value="spring" />

还要记得添加好struts2-spring-plugin-2.1.8.1.jar包这是要自己加到lib的

出去struts2自带的包antlr-2.7.2ss.jar

0 0