10:34:20,187 INFO Configuration: Reading mappings from resource: com/iustice/User.hbm.xml10:34:20,250 ERROR XMLHelper: Error parsing XML: XML InputStream(7) The content of element type "id" must match "(meta*,column*,type?,generator?)".10:34:20,250 ERROR XMLHelper: Error parsing XML: XML InputStream(10) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natu
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iustice">
<class name="User" table="user">
<id name="id" column="id">
<generator class="identity"></generator>
</id>
<property name="username" column="username" unique="true"/>
<property name="password" column="password" />
</class>
</hibernate-mapping><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="connection.url">jdbc:mysql://localhost/user</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">002312708</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.pool_size">10</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<!--
<property name="hbm2ddl.auto">create</property>
-->
<mapping resource="com/iustice/User.hbm.xml" /></session-factory></hibernate-configuration>
ublic class User implements Serializable {
private long id;
private String username;
private String password;
public User(){}
public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
public long getId(){
return id;
}
public void setId(long id){
this.id=id;
}
}public class Login extends ActionForm {
private String password;
private String username;
public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
} public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest) {
/** @todo: finish this method, this is just the skeleton.*/
return null;
} public void reset(ActionMapping actionMapping,
HttpServletRequest servletRequest) {
}
}
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
NoSuchMethodException, InvocationTargetException,
IllegalAccessException {
String username=(String)PropertyUtils.getSimpleProperty(form,"username");
String password=(String)PropertyUtils.getSimpleProperty(form,"password");
Session s=HibernateUtil.currentionSession();
Query q=s.createQuery("from User u where u.username='"+username+"' and password='"+password+"'");
if(q.list().isEmpty()){
HibernateUtil.closeSession();
return(mapping.findForward("loginfail"));
}
else{
HibernateUtil.closeSession();
request.getSession().setAttribute(username,username);
return mapping.findForward("loginsuccess");
}
}}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iustice">
<class name="User" table="user">
<id name="id" column="id">
<generator class="identity"></generator>
</id>
<property name="username" column="username" unique="true"/>
<property name="password" column="password" />
</class>
</hibernate-mapping><?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="connection.url">jdbc:mysql://localhost/user</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">002312708</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.pool_size">10</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<!--
<property name="hbm2ddl.auto">create</property>
-->
<mapping resource="com/iustice/User.hbm.xml" /></session-factory></hibernate-configuration>
ublic class User implements Serializable {
private long id;
private String username;
private String password;
public User(){}
public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
public long getId(){
return id;
}
public void setId(long id){
this.id=id;
}
}public class Login extends ActionForm {
private String password;
private String username;
public String getPassword() {
return password;
} public void setPassword(String password) {
this.password = password;
} public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
} public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest) {
/** @todo: finish this method, this is just the skeleton.*/
return null;
} public void reset(ActionMapping actionMapping,
HttpServletRequest servletRequest) {
}
}
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws
NoSuchMethodException, InvocationTargetException,
IllegalAccessException {
String username=(String)PropertyUtils.getSimpleProperty(form,"username");
String password=(String)PropertyUtils.getSimpleProperty(form,"password");
Session s=HibernateUtil.currentionSession();
Query q=s.createQuery("from User u where u.username='"+username+"' and password='"+password+"'");
if(q.list().isEmpty()){
HibernateUtil.closeSession();
return(mapping.findForward("loginfail"));
}
else{
HibernateUtil.closeSession();
request.getSession().setAttribute(username,username);
return mapping.findForward("loginsuccess");
}
}}
解决方案 »
- jsp页面图片最后加载,如何做
- js动态添加和删除复选框
- 请教:文本框之间的相互关联
- 如何将bean文件中的一个哈西表或者数组中的所有值引用到javascript中,与一个变量值进行比对?
- jsp验证码问题
- 浏览器上不停的输出'null',什么原因?(在线等待,谢谢)
- DATETIME 设置的问题?如'9999-12-31 23:59:59'后面多个零??
- 关于jsp页面的中文乱码问题,求解!
- 如何配置log4j每天产生日志,并且当天日志大于10M时自动生成另一个文件
- 本人要写硕士论文,可惜所作项目(java,jsp,servlet,weblogic---> MIS )实在没法挖掘出符合硕士论文要求的题目,哪位有经验的大侠帮忙指
- 项目经理需要会那些软件?需要那些能力?
- 菜鸟问题,请指点!!
估计又是文件编码格式的吧,你将xml文件的存储格式改为UTF-8试试
要是不行,我也没有办法了