SSH框架---简单整合登录注册
来源:互联网 发布:传世sf番茄网络 编辑:程序博客网 时间:2024/06/07 05:22
1.这里用的是struts2+spring2+hibernate3.1。用到user表
2.请确定jar包不要重复。
3.用到了struts2的validation框架。spring的配置文件applicationContext.xml,如果启动fwq发现无法加载此配置,请放置到WEB-INF下。hibernate通过映射关联表格,和字段。如果出现不能为空的错误,请在user.hbm.xml中检查字段属性和配置属性有否冲突。比如:
时间輚不能为空的。
从数据库开始说起。
一,设计方式接口——实现类(这里用的是老紫竹留言本的数据库部分代码)
接口实现如干方法,实现类实现接口中的所有方法。
二,
以上是hibernate.cfg.xml的配置
这句必须有。不然会报错。如果不加上对应的是实现类中的错误。
三,表的映射关系
类似javabean的一个类文件,属性对应表中的字段,一个实例对应一条记录。
以上是表的xml文件
(对数据库的操作通过po来实现)
下面是struts2部分。
一,
以上是struts.xml的部分配置(有于整合的spring本来action 后面的class是逻辑处理类的class文件,现在只是一个表示,这个表示用于spring识别这个action)
二,在action中通过提供一个上面的数据库操作接口的get方法,让spring调用的
类似这个样子。
action负责通过接口对象调用实现类完成登陆和注册功能,返回表示success,和input来转到不通的视图。
三,validation.xml更具不通的action类名字,来提供效验文件,这里提供的是LoginAction-validation.xml和ZjregisterAction-validation.xml
部分效验文件,虽然有这个文件,但strtus2还是会去访问action中的validate方法的。
spring部分
一,
2.请确定jar包不要重复。
3.用到了struts2的validation框架。spring的配置文件applicationContext.xml,如果启动fwq发现无法加载此配置,请放置到WEB-INF下。hibernate通过映射关联表格,和字段。如果出现不能为空的错误,请在user.hbm.xml中检查字段属性和配置属性有否冲突。比如:
查看复制到剪切板打印
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
[XML] view plaincopy
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
[XML] view plain copy
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
时间輚不能为空的。
从数据库开始说起。
一,设计方式接口——实现类(这里用的是老紫竹留言本的数据库部分代码)
接口实现如干方法,实现类实现接口中的所有方法。
二,
查看复制到剪切板打印
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
[XML] view plaincopy
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
[XML] view plain copy
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
以上是hibernate.cfg.xml的配置
查看复制到剪切板打印
- <property name="current_session_context_class">thread</property>
[XML] view plaincopy
- <property name="current_session_context_class">thread</property>
[XML] view plain copy
- <property name="current_session_context_class">thread</property>
这句必须有。不然会报错。如果不加上对应的是实现类中的错误。
三,表的映射关系
类似javabean的一个类文件,属性对应表中的字段,一个实例对应一条记录。
查看复制到剪切板打印
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
[XML] view plaincopy
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
[XML] view plain copy
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
以上是表的xml文件
(对数据库的操作通过po来实现)
下面是struts2部分。
一,
查看复制到剪切板打印
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
[XML] view plaincopy
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
[XML] view plain copy
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
以上是struts.xml的部分配置(有于整合的spring本来action 后面的class是逻辑处理类的class文件,现在只是一个表示,这个表示用于spring识别这个action)
二,在action中通过提供一个上面的数据库操作接口的get方法,让spring调用的
查看复制到剪切板打印
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
[Java] view plaincopy
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
[Java] view plain copy
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
类似这个样子。
action负责通过接口对象调用实现类完成登陆和注册功能,返回表示success,和input来转到不通的视图。
三,validation.xml更具不通的action类名字,来提供效验文件,这里提供的是LoginAction-validation.xml和ZjregisterAction-validation.xml
查看复制到剪切板打印
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
[XML] view plaincopy
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
[XML] view plain copy
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
部分效验文件,虽然有这个文件,但strtus2还是会去访问action中的validate方法的。
spring部分
一,
查看复制到剪切板打印
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
[XML] view plaincopy
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
[XML] view plain copy
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
1.这里用的是struts2+spring2+hibernate3.1。用到user表
2.请确定jar包不要重复。
3.用到了struts2的validation框架。spring的配置文件applicationContext.xml,如果启动fwq发现无法加载此配置,请放置到WEB-INF下。hibernate通过映射关联表格,和字段。如果出现不能为空的错误,请在user.hbm.xml中检查字段属性和配置属性有否冲突。比如:
时间輚不能为空的。
从数据库开始说起。
一,设计方式接口——实现类(这里用的是老紫竹留言本的数据库部分代码)
接口实现如干方法,实现类实现接口中的所有方法。
二,
以上是hibernate.cfg.xml的配置
这句必须有。不然会报错。如果不加上对应的是实现类中的错误。
三,表的映射关系
类似javabean的一个类文件,属性对应表中的字段,一个实例对应一条记录。
以上是表的xml文件
(对数据库的操作通过po来实现)
下面是struts2部分。
一,
以上是struts.xml的部分配置(有于整合的spring本来action 后面的class是逻辑处理类的class文件,现在只是一个表示,这个表示用于spring识别这个action)
二,在action中通过提供一个上面的数据库操作接口的get方法,让spring调用的
类似这个样子。
action负责通过接口对象调用实现类完成登陆和注册功能,返回表示success,和input来转到不通的视图。
三,validation.xml更具不通的action类名字,来提供效验文件,这里提供的是LoginAction-validation.xml和ZjregisterAction-validation.xml
部分效验文件,虽然有这个文件,但strtus2还是会去访问action中的validate方法的。
spring部分
一,
2.请确定jar包不要重复。
3.用到了struts2的validation框架。spring的配置文件applicationContext.xml,如果启动fwq发现无法加载此配置,请放置到WEB-INF下。hibernate通过映射关联表格,和字段。如果出现不能为空的错误,请在user.hbm.xml中检查字段属性和配置属性有否冲突。比如:
查看复制到剪切板打印
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
[XML] view plaincopy
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
[XML] view plain copy
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
时间輚不能为空的。
从数据库开始说起。
一,设计方式接口——实现类(这里用的是老紫竹留言本的数据库部分代码)
接口实现如干方法,实现类实现接口中的所有方法。
二,
查看复制到剪切板打印
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
[XML] view plaincopy
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
[XML] view plain copy
- <hibernate-configuration>
- <session-factory>
- <property name="show_sql">true</property>
- <property name="myeclipse.connection.profile">Myway</property>
- <property name="connection.url">
- jdbc:mysql://localhost:3306/myway
- </property>
- <property name="connection.username">root</property>
- <property name="connection.password">1</property>
- <property name="connection.driver_class">
- com.mysql.jdbc.Driver
- </property>
- <property name="dialect">
- org.hibernate.dialect.MySQLDialect
- </property>
- <property name="current_session_context_class">thread</property>
- <mapping resource="myway/po/User.hbm.xml" />
- </session-factory>
- </hibernate-configuration>
以上是hibernate.cfg.xml的配置
查看复制到剪切板打印
- <property name="current_session_context_class">thread</property>
[XML] view plaincopy
- <property name="current_session_context_class">thread</property>
[XML] view plain copy
- <property name="current_session_context_class">thread</property>
这句必须有。不然会报错。如果不加上对应的是实现类中的错误。
三,表的映射关系
类似javabean的一个类文件,属性对应表中的字段,一个实例对应一条记录。
查看复制到剪切板打印
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
[XML] view plaincopy
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
[XML] view plain copy
- <hibernate-mapping>
- <class name="myway.po.User" table="user" catalog="myway">
- <id name="id" type="integer">
- <column name="id" />
- <generator class="assigned"></generator>
- </id>
- <property name="userid" type="string">
- <column name="userid" length="50" not-null="true" />
- </property>
- <property name="userpwd" type="string">
- <column name="userpwd" length="50" />
- </property>
- <property name="userques" type="string">
- <column name="userques" length="50" />
- </property>
- <property name="userans" type="string">
- <column name="userans" length="50" />
- </property>
- <property name="usermail" type="string">
- <column name="usermail" length="50" />
- </property>
- <property name="integral" type="integer">
- <column name="integral" />
- </property>
- <property name="grade" type="integer">
- <column name="grade" />
- </property>
- <property name="sex" type="string">
- <column name="sex" length="8" />
- </property>
- <property name="schoolname" type="string">
- <column name="schoolname" length="50" />
- </property>
- <property name="birthday" type="string">
- <column name="birthday" length="50" />
- </property>
- <property name="realname" type="string">
- <column name="realname" length="50" />
- </property>
- <property name="nicheng" type="string">
- <column name="nicheng" length="50" />
- </property>
- <property name="personalhobby" type="string">
- <column name="personalhobby" length="50" />
- </property>
- <property name="otherinfo" type="string">
- <column name="otherinfo" length="200" />
- </property>
- <property name="registime" type="timestamp">
- <column name="registime" length="0" not-null="false" />
- </property>
- </class>
- </hibernate-mapping>
以上是表的xml文件
(对数据库的操作通过po来实现)
下面是struts2部分。
一,
查看复制到剪切板打印
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
[XML] view plaincopy
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
[XML] view plain copy
- <struts>
- <constant name="struts.custom.i18n.resources" value="globalMessages"/>
- <constant name="struts.i18n.encodeing" value="UTF-8"/>
- <package name="Myway" extends="struts-default">
- <action name="zjreg" class="zjregisterAction">
- <result name="success" type="redirect" >/jsp/zjregisterinfo.jsp</result>
- <result name="input">/jsp/zjregister.jsp</result>
- </action>
- <action name="login" class="loginAction">
- <result name="success" type="redirect">/my_foot.jsp</result>
- <result name="input" type="redirect">/jsp/login.jsp</result>
- </action>
- </struts>
以上是struts.xml的部分配置(有于整合的spring本来action 后面的class是逻辑处理类的class文件,现在只是一个表示,这个表示用于spring识别这个action)
二,在action中通过提供一个上面的数据库操作接口的get方法,让spring调用的
查看复制到剪切板打印
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
[Java] view plaincopy
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
[Java] view plain copy
- private UserService userservice;
- public void setUserservice(UserService userservice) {
- this.userservice = userservice;
- }
类似这个样子。
action负责通过接口对象调用实现类完成登陆和注册功能,返回表示success,和input来转到不通的视图。
三,validation.xml更具不通的action类名字,来提供效验文件,这里提供的是LoginAction-validation.xml和ZjregisterAction-validation.xml
查看复制到剪切板打印
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
[XML] view plaincopy
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
[XML] view plain copy
- <validators>
- <field name="username">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>username should be write</message>
- </field-validator>
- </field>
- <field name="username">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>username must between 6 and 15 and also </message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="requiredstring">
- <param name="trim">true</param>
- <message>password should be write</message>
- </field-validator>
- </field>
- <field name="password">
- <field-validator type="regex">
- <param name="trim">ture</param>
- <param name="expression"><![CDATA[(/w{6,15})]]></param>
- <message>password must between 6 and 15 and also </message>
- </field-validator>
- </field>
- </validators>
部分效验文件,虽然有这个文件,但strtus2还是会去访问action中的validate方法的。
spring部分
一,
查看复制到剪切板打印
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
[XML] view plaincopy
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
[XML] view plain copy
- <bean id="userservice" class="myway.userinterface.imp.UserServiceHbimp"></bean>
- <bean id="loginAction" class="myway.action.LoginAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- <bean id="zjregisterAction" class="myway.action.ZjregAction" scope="prototype">
- <property name="userservice">
- <ref local="userservice"/>
- </property>
- </bean>
- </beans>
0 0
- SSH框架---简单整合登录注册
- SSH框架整合之注册登录
- SSH框架整合之注册登录 .
- 简单的SSH整合登录注册
- 简单的SSH整合登录注册
- 简单的SSH整合登录注册
- ssh整合--注册登录
- ssh框架登录注册
- ssh框架登录注册
- 整合ssh框架下注册登录的实现
- SSH框架整合注册登录下载链接【转】
- SSM框架整合---实现简单登录注册功能
- MyEclipse8.5配置整合SSH框架 简单登录验证功能
- MyEclipse2014整合SSH框架实现登录
- MyEclipse2014整合SSH框架实现登录
- SSH框架整合(用户登录)
- 求一个用SSH框架+mysql写的简单小实例,比如登录注册
- 一个用SSH框架开发的简单的登录注册系统
- JAVA 日期时间的工具类
- python学习笔记
- 社会沉思录
- Session技术细节详解
- 普通用户非root用户winscp连接linux时提示用户连接失败监测到超时的原因以及解决方案
- SSH框架---简单整合登录注册
- Android开源项目第二篇——工具库篇
- 用css/html制作简易bookstore网页
- poi生成excel表格(xls或者xlsx格式),多个工作sheet
- oracle11g 安装
- Python常用函数整理
- 继承与派生
- 利用参数宏进行角度与弧度的转换
- 外包不可缺少的十大前端框架