解决方案 »
- 大家帮帮忙,找下用SSH做的项目。
- SQLServer2000 不能连接hibernate
- eclipse插件开发中使用dom4j的问题
- 大家给我推荐本关于struts hibernate spring的好书吧
- struts底层问题
- 困惑,请问什么时候使用action名称,什么时候使用jsp名称?
- 请教如何将'号替换成"号 反过来"号替换成'号 谢谢
- log4j中的ConversionPattern有哪些啊?
- eclipse3中的 M8,M9,rc3版代表啥意思?
- weblogic 8.1 装好后运行jsp?我访问http://127.0.0.1:7001怎么访问不了呢?
- Springmvc设置静态资源文件访问异常
- struts无法返回返回json数据
package org.dao;
import org.model.Usertable;
public interface RegisterDao {
public void saveUsertable(Usertable usertable);
}这是.dao.imp的代码
package org.dao.imp;
import java.util.List;
import org.dao.RegisterDao;
import org.model.Usertable;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class RegisterDaoImp extends HibernateDaoSupport implements RegisterDao{
public void saveUsertable(Usertable usertable){
getHibernateTemplate().save(usertable);
}
}这是.service的代码
package org.service;
import org.model.Usertable;
public interface RegisterService {
public void saveUsertable(Usertable usertable);
}这是.service.imp的代码
package org.service.imp;
import org.dao.RegisterDao;
import org.model.Usertable;
import org.service.RegisterService;
public class RegisterServiceManage implements RegisterService{
private RegisterDao registerDao;
public void setRegisterDao(RegisterDao registerDao){
this.registerDao=registerDao;
}
public void saveUsertable(Usertable usertable){
this.registerDao.saveUsertable(usertable);
}
}这是action的代码
package org.action;
import java.util.Map;
import org.model.Usertable;
import org.service.RegisterService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class RegisterAction extends ActionSupport{
protected RegisterService registerService;
protected Usertable usertable;
public Usertable getUsertable(){
return this.usertable;
}
public void setUsertable(Usertable usertable){
this.usertable=usertable;
}
public void setRegisterService(RegisterService registerService){
this.registerService=registerService;
}
public String execute() throws Exception{
System.out.print(usertable.getUsername());
Usertable ut=new Usertable();
ut.setUsername(usertable.getUsername());
ut.setPassword(usertable.getPassword());
registerService.saveUsertable(ut);
return SUCCESS;
}
}这是jsp页面的代码
<body>
<div align="center">
<s:form action="register.action" method="post">
用户注册
<br/>
<s:textfield name="usertable.username" label="用户名" size="20"/>
<s:password name="usertable.password" label="密码" size="21"/>
<s:submit value="注册"></s:submit>
</s:form>
</div>
</body>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="org.model.Usertable" table="usertable" schema="dbo" catalog="seconddhand">
<id name="username" type="java.lang.String">
<column name="username" length="20" />
<generator class="native" />
</id>
<property name="password" type="java.lang.String">
<column name="password" length="15" not-null="true" />
</property>
</class>
</hibernate-mapping>