求助大佬,怎么将我这个jsp文件获取用户输入,并存入信息进数据库
<head><title>表单</title><scriptlanguage=JavaScriptsrc="script/regcheckdata.js"></scrip...
<head> <title>表单</title> <script language=JavaScript src="script/regcheckdata.js"></script> <meta http-equiv="content-type" content="text/html;charset=gb2312"> </head> <body> <form name="form" method="get" onSubmit="return checkdata()"> <table width="750" align="center" border="2"> <tr> <td colspan="2" align="center">用户注册</td> </tr> <tr> <td>用户名:</td> <td> <input type=text name="username" size="30" maxlength="10"> </td> </tr> <tr> <td>密码:</td> <td> <input type=password name="pwd" size="15" maxlength="12"> </td> </tr> <tr> <td>密码确认</td> <td> <input type=password name="pwd2" size="15" maxlength="12"> </td> </tr> <tr> <td>邮箱:</td> <td> <input type=text name="mail" size="30" > </td> </tr> <tr> <td>邮箱确认:</td> <td> <input type=text name="mail2" size="30" > </td> </tr> <tr> <td>性别</td> <td> <input type=radio name="sex" value="male" checked>男 <input type=radio name="sex" value="female">女 </td> </tr> <tr> <td>你来自</td> <td> <select name="province"> <option value=0 selected>请选择</option> <option value=0>其他</option> </select> </td> </tr> <tr> <td>兴趣爱好</td> <td> <input type="checkbox" name="music" value="vc" checked>音乐 <input type="checkbox" name="basketball" value="vb">篮球 <input type="checkbox" name="basketball" value="vfoxpro">足球 <input type="checkbox" name="reade" value="vjava">读书 <br> <input type="checkbox" name="swimming" value="bc">游泳 <input type="checkbox" name="pingpang" value="cobol">打乒乓球 <input type="checkbox" name="TV" value="java">看电视 <input type="checkbox" name="draw" value="delphi">画画 </td> </tr> <tr> <td>功能实现</td> <td align="center"> <input type="submit" value="提交"> <input type="reset" value="重置"> </td> </tr> </table> </form> </body></html>
展开
1个回答
展开全部
1、先写一个实体类,就叫做User吧;
2、再写hibernate的hbm配置文件,写UserDAO接口;
3、在写UserDAOHibernateImpl实现UserDAO,在写spring配置文件定义好Hibernate的各种属性;
4、再写一个UserService接口,然后就是根据spring的IOC写UserServiceImpl;
5、写struts,struts的action可以这样写:
public class RegisterAction{
private User user;
public User getUser(){
return user;
}
public void SetUser(User user){
this.user=user;
}
public String execute(){
String[] confs =
{"applicationContext.xml"};
ApplicationContext ac =
new ClassPathXmlApplicationContext(confs);
UserService userService = (UserService)
ac.getBean("userService");
try{
userService.register(user);
return "success";
}catch(Exception e){
return "error";
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询