6、Spring+Struts2+MyBatis(mybatis有代理)整合增删改查
1、创建如下的oracle脚本
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 create table userinfo 2 (id number(4), 3 name varchar2(50), 4 password varchar2(20 5 telephone varchar2(15), 6 isadmin varchar2(5)); 7 8 --4.2 用户表序列 9 create sequence seq_userinfo; 10 11 alter table userinfo add constraint pk_userinfo_id primary key(id); 12 13 insert into userinfo values(seq_userinfo.nextval,'holly','123','134518024 14 ','是'); 15 16 commit;
2、创建如下项目结构
3、在项目的WebRoot下的WEB-INF下的lib下添加如下jar文件
aopalliance.jar
aspectjweaver.jar
cglib-nodep-2.1_3.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
log4j-1.2.8.jar
mybatis-3.2.3.jar
mybatis-spring-1.2.1.jar
ognl-2.7.3.jar
ojdbc14.jar
org.springframework.aop-3.0.2.RELEASE.jar
org.springframework.asm-3.0.2.RELEASE.jar
org.springframework.beans-3.0.2.RELEASE.jar
org.springframework.context-3.0.2.RELEASE.jar
org.springframework.core-3.0.2.RELEASE.jar
org.springframework.expression-3.0.2.RELEASE.jar
org.springframework.jdbc-3.0.2.RELEASE.jar
org.springframework.orm-3.0.2.RELEASE.jar
org.springframework.transaction-3.0.2.RELEASE.jar
org.springframework.web-3.0.2.RELEASE.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar
4、在src下的com.bean包下创建UserInfo.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.bean; 2 3 public class UserInfo { 4 private Integer id; 5 private String name; 6 private String password; 7 private String telephone; 8 private String isadmin; 9 10 public UserInfo() { 11 12 } 13 public UserInfo(Integer id, String name, String password, String telephone, 14 String isadmin) { 15 this.id = id; 16 this.name = name; 17 this.password = password; 18 this.telephone = telephone; 19 this.isadmin = isadmin; 20 } 21 public Integer getId() { 22 return id; 23 } 24 public void setId(Integer id) { 25 this.id = id; 26 } 27 public String getName() { 28 return name; 29 } 30 public void setName(String name) { 31 this.name = name; 32 } 33 public String getPassword() { 34 return password; 35 } 36 public void setPassword(String password) { 37 this.password = password; 38 } 39 public String getTelephone() { 40 return telephone; 41 } 42 public void setTelephone(String telephone) { 43 this.telephone = telephone; 44 } 45 public String getIsadmin() { 46 return isadmin; 47 } 48 public void setIsadmin(String isadmin) { 49 this.isadmin = isadmin; 50 } 51 @Override 52 public String toString() { 53 return "UserInfo [id=" + id + ", isadmin=" + isadmin + ", name=" + name 54 + ", password=" + password + ", telephone=" + telephone + "]"; 55 } 56 57 58 }
5、在src下的com.dao包下创建UserInfoDao.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.dao; 2 3 import java.util.List; 4 5 import com.bean.UserInfo; 6 /** 7 * mybatis映射文件的dao接口 8 * @author pc 9 * 10 */ 11 public interface UserInfoDao { 12 public List<UserInfo> findAll(); //查所有 13 public UserInfo findUser(UserInfo user);//条件查询 14 public void insertUser(UserInfo user); //插入对象 15 public void updateUser(UserInfo user); //修改对象 16 public void deleteUser(int id); //条件删除 17 18 }
6、在src下的com.dao包下创建UserInfoDao.xml
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > 3 <mapper namespace="com.dao.UserInfoDao"> 4 <select id="findAll" resultType="user"> 5 select * from userinfo 6 </select> 7 <select id="findUser" resultType="user" parameterType="user"> 8 select * from userinfo where name=#{name} and password=#{password} 9 </select> 10 <insert id="insertUser" parameterType="user"> 11 insert into userinfo values(seq_userinfo.nextval,#{name},#{password},#{telephone},#{isadmin}) 12 </insert> 13 <update id="updateUser" parameterType="user"> 14 update userinfo set name=#{name},password=#{password},telephone=#{telephone},isadmin=#{isadmin} where id=#{id} 15 </update> 16 17 <delete id="deleteUser" parameterType="int"> 18 delete from userinfo where id=#{id} 19 </delete> 20 </mapper>
7、在src下创建mybatis-config.xml
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd" > 3 <configuration> 4 <!-- mybatis映射文件的别名配置 --> 5 <typeAliases> 6 <typeAlias type="com.bean.UserInfo" alias="user"/> 7 </typeAliases> 8 9 <!-- 注册mybatis的映射文件 --> 10 <mappers> 11 <mapper resource="com/dao/UserInfoDao.xml"/> 12 </mappers> 13 </configuration>
8、在src下的com.dao.impl包下创建UserInfoDaoImpl.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.dao.impl; 2 3 import java.util.List; 4 5 import org.mybatis.spring.SqlSessionTemplate; 6 7 import com.bean.UserInfo; 8 import com.dao.UserInfoDao; 9 /** 10 * 数据dao接口实现类 11 * @author pc 12 * 13 */ 14 public class UserInfoDaoImpl implements UserInfoDao { 15 private SqlSessionTemplate sqlSession; 16 /** 17 * 根据id删除 18 */ 19 public void deleteUser(int id) { 20 //获取代理对象 21 UserInfoDao dao=sqlSession.getMapper(UserInfoDao.class); 22 try { 23 dao.deleteUser(id); //调用代理对象映射的dao接口删除 24 sqlSession.commit(); //提交事务 25 System.out.println("删除成功"); 26 } catch (Exception e) { 27 System.out.println("删除失败"); 28 e.printStackTrace(); 29 } 30 } 31 /** 32 * 查询所有 33 */ 34 public List<UserInfo> findAll() { 35 //获取代理对象 36 UserInfoDao dao=sqlSession.getMapper(UserInfoDao.class); 37 List<UserInfo> list=null; 38 try { 39 list=dao.findAll(); 40 System.out.println("查询所有成功"); 41 } catch (Exception e) { 42 System.out.println("查询所有失败"); 43 e.printStackTrace(); 44 } 45 return list; 46 } 47 48 /** 49 * 条件查询 50 */ 51 public UserInfo findUser(UserInfo user) { 52 //获取代理对象 53 UserInfoDao dao=sqlSession.getMapper(UserInfoDao.class); 54 UserInfo userinfo=null; 55 try { 56 if(user!=null){ 57 userinfo=dao.findUser(user); 58 System.out.println("条件查询成功"); 59 }else{ 60 System.out.println("条件查询参数为空"); 61 } 62 } catch (Exception e) { 63 System.out.println("条件查询失败"); 64 e.printStackTrace(); 65 } 66 return userinfo; 67 } 68 /** 69 *添加 70 */ 71 public void insertUser(UserInfo user) { 72 //获取代理对象 73 UserInfoDao dao=sqlSession.getMapper(UserInfoDao.class); 74 try { 75 if(user!=null){ 76 dao.insertUser(user); 77 sqlSession.commit(); //提交事务 78 System.out.println("添加成功"); 79 }else{ 80 System.out.println("添加参数为空"); 81 } 82 } catch (Exception e) { 83 System.out.println("添加失败"); 84 e.printStackTrace(); 85 } 86 87 } 88 /** 89 * 修改对象 90 */ 91 public void updateUser(UserInfo user) { 92 //获取代理对象 93 UserInfoDao dao=sqlSession.getMapper(UserInfoDao.class); 94 try { 95 if(user!=null){ 96 dao.updateUser(user); 97 sqlSession.commit(); //提交事务 98 System.out.println("修改成功"); 99 }else{ 100 System.out.println("修改参数为空"); 101 } 102 } catch (Exception e) { 103 System.out.println("修改失败"); 104 e.printStackTrace(); 105 } 106 } 107 public SqlSessionTemplate getSqlSession() { 108 return sqlSession; 109 } 110 public void setSqlSession(SqlSessionTemplate sqlSession) { 111 this.sqlSession = sqlSession; 112 } 113 114 115 }
9、在src下的com.service包下创建UserInfoService.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.service; 2 3 import java.util.List; 4 5 import com.bean.UserInfo; 6 /** 7 * 服务接口 8 * @author pc 9 * 10 */ 11 public interface UserInfoService { 12 public List<UserInfo> findAll(); //查所有 13 public UserInfo findUser(UserInfo user);//条件查询 14 public void insertUser(UserInfo user); //插入对象 15 public void updateUser(UserInfo user); //修改对象 16 public void deleteUser(int id); //条件删除 17 18 19 }
9、在src下的com.service.impl包下创建UserInfoServiceImpl.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.service.impl; 2 3 import java.util.List; 4 5 import com.bean.UserInfo; 6 import com.dao.UserInfoDao; 7 import com.dao.impl.UserInfoDaoImpl; 8 import com.service.UserInfoService; 9 10 public class UserInfoServiceImpl implements UserInfoService{ 11 //引入数据层接口 12 UserInfoDao dao=new UserInfoDaoImpl(); 13 /** 14 * 删除 15 */ 16 public void deleteUser(int id) { 17 dao.deleteUser(id); 18 } 19 /** 20 * 查所有 21 */ 22 public List<UserInfo> findAll() { 23 return dao.findAll(); 24 } 25 /** 26 * 条件查询 27 */ 28 public UserInfo findUser(UserInfo user) { 29 return dao.findUser(user); 30 } 31 /** 32 * 插入对象 33 */ 34 public void insertUser(UserInfo user) { 35 dao.insertUser(user); 36 } 37 /** 38 * 修改对象 39 */ 40 public void updateUser(UserInfo user) { 41 dao.updateUser(user); 42 } 43 44 45 public UserInfoDao getDao() { 46 return dao; 47 } 48 public void setDao(UserInfoDao dao) { 49 this.dao = dao; 50 } 51 52 }
10、在src下的com.action包下创建UserInfoAction.java
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package com.action; 2 3 import com.bean.UserInfo; 4 import com.opensymphony.xwork2.Action; 5 import com.opensymphony.xwork2.ActionSupport; 6 import com.service.UserInfoService; 7 import com.service.impl.UserInfoServiceImpl; 8 /** 9 * 10 * @author pc 11 * ActionSupport可以最数据校验 12 */ 13 public class UserInfoAction extends ActionSupport { 14 15 /** 16 * 引用服务层对象 17 */ 18 private UserInfoService service=new UserInfoServiceImpl(); 19 /** 20 * 对象用于接收请求中的值 21 * 必须创建setter和getter方法,代理对象才能获取或设置 22 */ 23 private UserInfo user; 24 /** 25 * 登录 26 * @return 27 */ 28 public String login(){ 29 30 if(user!=null){ 31 System.out.println("登录表单值接收到"); 32 UserInfo userinfo=service.findUser(user); 33 if(userinfo!=null){ 34 System.out.println("登录陈宫"); 35 return SUCCESS; 36 37 }else{ 38 return ERROR; 39 } 40 41 42 }else{ 43 System.out.println("登录表单值没有接收到"); 44 return ERROR; 45 46 } 47 } 48 49 /** 50 * 注册 51 * @return 52 */ 53 public String register(){ 54 if(user!=null){ 55 System.out.println("注册表单值接收到"); 56 service.insertUser(user); 57 System.out.println("action注册成功"); 58 return SUCCESS; 59 60 }else{ 61 System.out.println("注册表单值没有接收到"); 62 return ERROR; 63 64 } 65 } 66 67 public UserInfoService getService() { 68 return service; 69 } 70 71 public void setService(UserInfoService service) { 72 this.service = service; 73 } 74 75 public UserInfo getUser() { 76 return user; 77 } 78 79 public void setUser(UserInfo user) { 80 this.user = user; 81 } 82 83 84 85 }
11、在src下创建applicationContext.xml
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> 3 <!-- 1.配置数据源 --> 4 <bean id="oracleDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 5 <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 6 <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/> 7 <property name="username" value="scott"/> 8 <property name="password" value="tiger"/> 9 </bean> 10 11 <!-- 3.事务管理session工厂 --> 12 <!-- 事务配置 --> 13 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 14 <property name="dataSource" ref="oracleDataSource"/> 15 </bean> 16 17 <!--2.在sqlSessionFactory中注入数据源 --> 18 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 19 <!-- 注入数据源 --> 20 <property name="dataSource" ref="oracleDataSource"/> 21 22 <!-- 引用mybatis的主配置文件,(注册dao映射文件) --> 23 <property name="configLocation"> 24 <value>classpath:mybatis-config.xml</value> 25 </property> 26 </bean> 27 28 29 30 <!-- 3.用构造获取sqlSessionTemplate --> 31 <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> 32 <constructor-arg ref="sqlSessionFactory"/> 33 </bean> 34 35 <!-- 4.dao注入sqlSesson --> 36 <bean id="userdao" class="com.dao.impl.UserInfoDaoImpl"> 37 <property name="sqlSession" ref="sqlSessionTemplate"/> 38 </bean> 39 40 <!-- 5.service注入dao --> 41 <bean id="servicedao" class="com.service.impl.UserInfoServiceImpl"> 42 <property name="dao" ref="userdao"/> 43 </bean> 44 45 <!-- 6.在Action中注入service --> 46 <bean id="userAction" class="com.action.UserInfoAction"> 47 <property name="service" ref="servicedao"/> 48 </bean> 49 </beans>
12、在src下创建struts.xml
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "struts-2.1.dtd" > 3 <struts> 4 <!-- 中文乱码处理 --> 5 <constant name="struts.i18n.encoding" value="UTF-8"/> 6 7 8 <package name="default" namespace="/" extends="struts-default"> 9 10 11 <!-- method是对应action类的有返回值的方法名 --> 12 <!-- 登录,注册,通配符设置,动态调用方法,*表示Login或register --> 13 <action name="*" class="userAction" method="{1}"> 14 <result name="input">{1}.jsp</result> 15 <result name="success">success.jsp</result> 16 <result name="error">error.jsp</result> 17 </action> 18 19 20 </package> 21 </struts>
13、编辑WebRoot下的WEB-INF下的web.xml
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 3 <context-param> 4 <param-name>contextConfigLocation</param-name> 5 <param-value>classpath:applicationContext.xml</param-value> 6 </context-param> 7 <listener> 8 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 9 </listener> 10 <filter> 11 <filter-name>struts2</filter-name> 12 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 13 </filter> 14 15 <filter-mapping> 16 <filter-name>struts2</filter-name> 17 <url-pattern>/*</url-pattern> 18 </filter-mapping> 19 20 <welcome-file-list> 21 <welcome-file>login.jsp</welcome-file> 22 </welcome-file-list> 23 24 </web-app>
14、在WebRoot下创建register.jsp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>My JSP 'index.jsp' starting page</title> 13 <meta http-equiv="pragma" content="no-cache"> 14 <meta http-equiv="cache-control" content="no-cache"> 15 <meta http-equiv="expires" content="0"> 16 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 17 <meta http-equiv="description" content="This is my page"> 18 <!-- 19 <link rel="stylesheet" type="text/css" href="styles.css"> 20 --> 21 </head> 22 23 <body> 24 <center> 25 <fieldset style="width:400px;"> 26 <legend>注册</legend> 27 <form action="registerUser.action" method="post"> 28 <table> 29 <tr> 30 <td>用户名:</td> 31 <td><input type="text" name="user.name"/></td> 32 </tr> 33 <tr> 34 <td>密码:</td> 35 <td><input type="password" name="user.password"/></td> 36 </tr> 37 <tr> 38 <td>电话号码:</td> 39 <td><input type="text" name="user.telephone"/></td> 40 </tr> 41 <tr> 42 <td>是否是管理员:</td> 43 <td> 44 <input type="radio" name="user.isadmin" value="是"> 45 <input type="radio" name="user.isadmin" value="否" checked="checked"/> 46 </td> 47 </tr> 48 <tr> 49 <td><input type="submit" value="提交"/></td> 50 <td><input type="reset" value="重置"/></td> 51 </tr> 52 </table> 53 54 </form> 55 </fieldset> 56 </center> 57 </body> 58 </html>
15、在WebRoot下创建login.jsp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>My JSP 'index.jsp' starting page</title> 13 <meta http-equiv="pragma" content="no-cache"> 14 <meta http-equiv="cache-control" content="no-cache"> 15 <meta http-equiv="expires" content="0"> 16 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 17 <meta http-equiv="description" content="This is my page"> 18 <!-- 19 <link rel="stylesheet" type="text/css" href="styles.css"> 20 --> 21 </head> 22 23 <body> 24 <center> 25 <fieldset style="width:400px;"> 26 <legend>登录</legend> 27 <form action="login.action" method="post"> 28 <table> 29 <tr> 30 <td>用户名:</td> 31 <td><input type="text" name="user.name"/></td> 32 </tr> 33 <tr> 34 <td>密码:</td> 35 <td><input type="password" name="user.password"/></td> 36 </tr> 37 <tr> 38 <td><input type="submit" value="提交"/></td> 39 <td><input type="reset" value="重置"/></td> 40 </tr> 41 </table> 42 43 </form> 44 </fieldset> 45 </center> 46 </body> 47 </html>
16、在WebRoot下创建success.jsp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <%@taglib uri="/struts-tags" prefix="s"%> 3 <% 4 String path = request.getContextPath(); 5 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 6 %> 7 8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 9 <html> 10 <head> 11 <base href="<%=basePath%>"> 12 13 <title>My JSP 'index.jsp' starting page</title> 14 <meta http-equiv="pragma" content="no-cache"> 15 <meta http-equiv="cache-control" content="no-cache"> 16 <meta http-equiv="expires" content="0"> 17 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 18 <meta http-equiv="description" content="This is my page"> 19 <!-- 20 <link rel="stylesheet" type="text/css" href="styles.css"> 21 --> 22 </head> 23 24 <body> 25 <h1>操作成功</h1> 26 <s:if test="user.name eq 'holly'"> 27 holly你来啦? 28 </s:if> 29 <s:else> 30 我不认识你?你是谁? 31 </s:else> 32 </body> 33 </html>
17、在WebRoot下创建error.jsp
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 5 %> 6 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 8 <html> 9 <head> 10 <base href="<%=basePath%>"> 11 12 <title>My JSP 'index.jsp' starting page</title> 13 <meta http-equiv="pragma" content="no-cache"> 14 <meta http-equiv="cache-control" content="no-cache"> 15 <meta http-equiv="expires" content="0"> 16 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 17 <meta http-equiv="description" content="This is my page"> 18 <!-- 19 <link rel="stylesheet" type="text/css" href="styles.css"> 20 --> 21 </head> 22 23 <body> 24 操作失败! 25 </body> 26 </html>
18、运行
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> </head> <body> <center> <fieldset style="width:400px;"> <legend>注册</legend> <form action="registerUser.action" method="post"> <table> <tr> <td>用户名:</td> <td><input type="text" name="user.name"/></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="user.password"/></td> </tr> <tr> <td>电话号码:</td> <td><input type="text" name="user.telephone"/></td> </tr> <tr> <td>是否是管理员:</td> <td> <input type="radio" name="user.isadmin" value="是"> <input type="radio" name="user.isadmin" value="否" checked="checked"/> </td> </tr> <tr> <td><input type="submit" value="提交"/></td> <td><input type="reset" value="重置"/></td> </tr> </table> </form> </fieldset> </center> </body></html>