MyEclipse8.6版的SSH实验 联系客服

发布时间 : 星期三 文章MyEclipse8.6版的SSH实验更新完毕开始阅读bad3baa1998fcc22bdd10d39

struts.url.includeParams = get

struts.custom.i18n.resources=messageResource struts.dispatcher.parametersWorkaround = false

### See the StrutsBeanWrapper javadocs for more information struts.freemarker.wrapper.altMap=true struts.xslt.nocache=false

### A list of configuration files automatically loaded by Struts struts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml

struts.mapper.alwaysSelectFullNamespace=false (3)

信息资源属性文件

// messageResource_zh_CN.properties

对应的ASCII码为:

loginPage=\登\录\页\面 errorPage=\错\误\页\面 succPage=\成\功\页\面

failTip=\对\不\起\,\您\不\能\登\录\!\用\户\名\或\密\码\错\误\!

succTip=\欢\迎\,${0},\您\已\经\登\录\! user=\用\户\名 sex=\性 \别 age=\年 \龄 birth=\生 \日 pass=\密 \码

login=\登\录 reset=\重\置

user.required=\用\户\名\必\须\输\入\! pass.required=\密\码\必\须\输\入\!

这里包含所有的国际资源编码,本实验是写了中文,大家也可以使用其他的语言。

3. 在Web.xml中配置Spring的IoC容器和Struts2的前台控制器 系统自动生成的web.xml为:

xmlns=\

xmlns:xsi=\ xsi:schemaLocation=\ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\>

index.jsp

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2 /*

其中url-pattern是在与struts2交互时确定的。

配置之后的web.xml为: //web.xml

xmlns=\

xmlns:xsi=\ xsi:schemaLocation=\ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\>

index.jsp

>

contextConfigLocation

/WEB-INF/classes/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2 /*

encoding UTF-8

Struts.xml基本上分为三部分: (1) 上下文参数;

(2) Spring容器的Listener;

(3) 定义Struts2的FilterDispathcer的Filter。

4. 配置本项目的上下文环境

本实验把Hibernate的配置文件和Spring的配置文件整合,即全由Spring来管理。

// applicationContext.xml(请注意,此代码中包含连接数据库的用户名和密码信息,请根据实际情况加以修改)

系统自动产生的applicationContext.xml为: // applicationContext.xml

class=\>

org.hibernate.dialect.SQLServerDialect

class=\>

value=\>

value=\>

xmlns=\ xmlns:xsi=\ xmlns:p=\

xsi:schemaLocation=\

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\>

com/domain/Users.hbm.xml

系统自动产生的applicationContext.xml包含3部分: (1) 数据源dataSource的配置;

(2) 会话工厂sessionFactory的配置; (3) DAO UsersDAO的配置。

完整配置以后的applicationContext.xml