关于SSI整合之CRUD
1. 项目目录结构图
2.项目中所使用的 jar 包
3.Action 层
3.1 Action类
package com.zhanggaosong.ssi.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;import com.zhanggaosong.ssi.domain.User;import com.zhanggaosong.ssi.service.UserService;public class UserAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private User user; private UserService userService;public UserService getUserService() {
return userService; }public void setUserService(UserService userService) {
this.userService = userService; }public User getUser() {
return user; }public void setUser(User user) {
this.user = user; }public UserAction() {
}/**
* 用户登录方法 */ public String login() throws Exception { User u = userService.isUser(user); if (u != null) { ActionContext.getContext().getSession().put("user", u); return SUCCESS; } else { return INPUT; } } /** * 查询所有用户方法 */ public String queryall() throws Exception { List<User> list = userService.selectUser(); if(list!=null){ HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("userList",list); return SUCCESS; }else{ return INPUT; } } /** * 用户注册方法 */ public String register() throws Exception { boolean flag = userService.saveUser(user); if(flag==true){ return SUCCESS; }else{ return ERROR; } } /** * 删除用户信息方法 */ public String delete() throws Exception { //获取request对象 HttpServletRequest request = ServletActionContext.getRequest(); String userName=request.getParameter("name"); boolean flag = userService.deleteUser(userName); if(flag==true){ return SUCCESS; }else{ return ERROR; } } /** * 用户信息修改 */ public String update() throws Exception { boolean flag = userService.updateUser(user); if(flag==true){ return SUCCESS; }else{ return ERROR; } }}3.2 对应配置文件
3.2.1 UserAction-login-validation.xml
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.3//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.3.dtd"><validators> <field name="user.name"> <field-validator type="requiredstring"> <message>用户名不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <param name="maxLength">12</param> <message>用户名长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field> <field name="user.password"> <field-validator type="requiredstring"> <message>密码不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <param name="maxLength">18</param> <message>密码长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field></validators>3.2.2 UserAction-register-validation.xml
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.3//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.3.dtd"><validators> <field name="user.name"> <field-validator type="requiredstring"> <message>用户名不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <param name="maxLength">12</param> <message>用户名长度必须在${minLength}和${maxLength}之间</message> </field-validator></field> <field name="user.password"> <field-validator type="requiredstring"> <message>密码不能为空</message> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <param name="maxLength">18</param> <message>密码长度必须在${minLength}和${maxLength}之间</message> </field-validator> </field></validators>4.Dao层
4.1 dao 接口层
4.1.1 userDao
package com.zhanggaosong.ssi.dao;
import java.util.List;
import com.zhanggaosong.ssi.domain.User;
public interface UserDao {
/** * 判断登录用户是否存在 */ public User isUser(User user);/**
* 查询所有用户 */ public List<User> selectUser(); /** * 添加用户 */ public boolean saveUser(User user); /** * 修改用户信息 */ public boolean updateUser(User user); /** * 删除用户 */ public boolean deleteUser(String userName);}4.2 dao 实现层
4.2.1 UserDaoImpl
package com.zhanggaosong.ssi.dao;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;import com.zhanggaosong.ssi.domain.User;
public class UserDaoImpl extends SqlMapClientDaoSupport implements UserDao {
/**
* 判断登录用户是否存在 */ public User isUser(User user) {@SuppressWarnings("unchecked")
List<User> list = this.getSqlMapClientTemplate().queryForList( "selectUserByUsernameandPassword", user); if (list != null && list.size() > 0) { return list.get(0); } else { HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("error", "用户名或密码错误!"); return null; } }/**
* 查询所有用户 */ public List<User> selectUser() {@SuppressWarnings("unchecked")
List<User> list = this.getSqlMapClientTemplate().queryForList( "selectUser");if (list != null && list.size() > 0) {
return list; } else { return null; } }/**
* 根据用户名查找用户是否存在 */ public boolean selectByName(User user) { boolean flag = false; @SuppressWarnings("unchecked") List<User> list = this.getSqlMapClientTemplate().queryForList( "selectUserByUsername", user.getName()); if (list != null && list.size() > 0) { flag = true; } return flag; }/**
* 添加用户 */ public boolean saveUser(User user) {boolean flag = true;
// 第一步 查询数据库表中是否存在(调用selectByName()方法) boolean f = selectByName(user);// 第二步 根据查询结果判断是否插入数据
// 如果为true表示已存在 不能插入数据 if (f == true) { HttpServletRequest request = ServletActionContext.getRequest(); request.setAttribute("addUserName","用户名已存在请重新输入用户名"); return false; } else { //否则插入数据 注意插入的写法 flag = this.getSqlMapClientTemplate().insert("insertUser", user) != null; if (flag==false) { //插入成功 返回true return true; } else { //失败 返回false return false; } } }/**
* 修改用户信息 */ public boolean updateUser(User user) { int falg = this.getSqlMapClientTemplate().update("updateByName", user); if(falg>0){ return true; }else{ return false; } }/**
* 删除用户 */ public boolean deleteUser(String userName) { int flag= this.getSqlMapClientTemplate().delete("deleteTestByName",userName); if(flag>0){ return true; } return false; }}5.service层
5.1service 接口层
5.1.1 userService
package com.zhanggaosong.ssi.service;
import java.util.List;
import com.zhanggaosong.ssi.domain.User;
public interface UserService {
/** * 判断登录用户是否存在 */ public User isUser(User user);/**
* 查询所有用户 */ public List<User> selectUser(); /** * 添加用户 */ public boolean saveUser(User user); /** * 修改用户信息 */ public boolean updateUser(User user); /** * 删除用户 */ public boolean deleteUser(String userName);}5.2 service 实现层
5.2.1 UserServiceImpl
package com.zhanggaosong.ssi.service;
import java.util.List;
import com.zhanggaosong.ssi.dao.UserDao;
import com.zhanggaosong.ssi.domain.User;public class UserServiceImpl implements UserService {
private UserDao userDao;
public UserDao getUserDao() {
return userDao; }public void setUserDao(UserDao userDao) {
this.userDao = userDao; } /** * 判断登录用户是否存在 */ public User isUser(User user) { user.getName().trim(); user.getPassword().trim(); return userDao.isUser(user); }/**
* 查询所有用户 */ public List<User> selectUser() { return userDao.selectUser(); } /** * 添加用户 */ public boolean saveUser(User user) { user.getName().trim(); user.getPassword().trim(); return userDao.saveUser(user); }/**
* 修改用户信息 */ public boolean updateUser(User user) { return userDao.updateUser(user); }/**
* 删除用户 */ public boolean deleteUser(String userName) { return userDao.deleteUser(userName); }}
6. 实体层
6.1 实体类
6.1.1 User
package com.zhanggaosong.ssi.domain;
public class User {
private Integer id; private String name; private String password; public Integer getId() { return id; }public void setId(Integer id) {
this.id = id; }public User() {
}public String getName() {
return name; }public void setName(String name) {
this.name = name; }public String getPassword() {
return password; }public void setPassword(String password) {
this.password = password; }public User(String name, String password) {
this.name = name; this.password = password; }}
6.2实体类对应配置文件
6.2.1 user.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"><sqlMap namespace="user">
<typeAlias alias="User" type="com.zhanggaosong.ssi.domain.User" /> <resultMap id="UserResult" class="User"> <result property="name" column="name" /> <result property="password" column="password" /> </resultMap><!-- 根据姓名和密码判断用户是否存在 from 后面的表名 要与数据库中一致 -->
<select id="selectUserByUsernameandPassword" parameterClass="User" resultClass="User"> <![CDATA[ select name, password from user where name=#name# and password=#password# ]]> </select><!-- 根据姓名判断用户是否存在 -->
<select id="selectUserByUsername" parameterClass="string" resultClass="User"> <![CDATA[ select name, password from user where name=#name# ]]> </select><!-- 查询所有用户信息 -->
<select id="selectUser" parameterClass="String" resultClass="User"> <![CDATA[ select name, password from user order by id desc ]]> </select><!-- 添加用户 -->
<insert id="insertUser" parameterClass="User"> <![CDATA[ insert into user ( name, password) values ( #name#,#password# ) ]]> </insert><delete id="deleteTestByName" parameterClass="string">
<![CDATA[ delete from user where name = #name# ]]> </delete> <update id="updateByName" parameterClass="User"> update user set password = #password# where name = #name# </update></sqlMap>7. 配置文件
7.1 ibatis 配置文件
7.1.1 sqlMapConfig.xml
sqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"><sqlMapConfig>
<sqlMap resource="com/zhanggaosong/ssi/domain/user.xml" /></sqlMapConfig>7.2 spring 配置文件
7.2.1 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><import resource="db-applicationContext.xml"/>
<import resource="user-applicationContext.xml"/></beans>7.2.2 db-applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"> <property name="driverClassName"> <value>${jdbc.driver}</value> </property> <property name="url"> <value>${jdbc.url}</value> </property> <property name="username"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> <property name="minIdle"> <value>1</value> </property> <property name="maxActive"> <value>25</value> </property> <property name="maxIdle"> <value>5</value> </property> </bean><bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource"> <ref local="dataSource" /> </property> </bean><bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation"> <value>classpath:ibatis/sqlMapConfig.xml</value> </property> <property name="dataSource"> <ref local="dataSource" /> </property> </bean><!-- *************************************************************************** -->
<!-- 告诉事务管理器 那些方法下需要由Spring 去管理事务 --> <tx:advice id="tx" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" isolation="DEFAULT" propagation="REQUIRED" read-only="false" /> <tx:method name="update*" isolation="DEFAULT" propagation="REQUIRED" read-only="false" /> <tx:method name="delete*" isolation="DEFAULT" propagation="REQUIRED" read-only="false" /> <tx:method name="*" isolation="DEFAULT" propagation="REQUIRED" read-only="true" /> </tx:attributes> </tx:advice><!-- 告诉事务管理器 那些包以及那些类下需要Spring 去管理事务(一定是在SERVICE层上处理事务) -->
<aop:config> <aop:pointcut expression="execution(* com.zhanggaosong.ssi.service.*.*(..))" id="perform" /> <aop:advisor pointcut-ref="perform" advice-ref="tx" /> </aop:config></beans>7.2.3 user-applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><bean id="userDao" class="com.zhanggaosong.ssi.dao.UserDaoImpl">
<property name="sqlMapClient"> <ref bean="sqlMapClient" /> </property> </bean><bean id="userService" class="com.zhanggaosong.ssi.service.UserServiceImpl">
<property name="userDao"> <ref bean="userDao" /> </property> </bean><bean id="userAction" class="com.zhanggaosong.ssi.action.UserAction" scope="prototype">
<property name="userService"> <ref bean="userService" /> </property> </bean></beans>7.3 struts 配置文件
7.3.1 user-struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
<package name="userAction" extends="struts-default"> <!-- 登录 --> <action name="login" class="com.zhanggaosong.ssi.action.UserAction" method="login"> <result name="success">${pageContext.request.contextPath}/pages/success.jsp</result> <result name="input">index.jsp</result> </action> <!-- 注册 --> <action name="register" class="com.zhanggaosong.ssi.action.UserAction" method="register"> <result name="success" type="redirectAction"> <param name="actionName">queryall</param> <param name="namespace">/</param> </result> <result name="input">${pageContext.request.contextPath}/pages/register.jsp</result> <result name="error">${pageContext.request.contextPath}/pages/register.jsp</result> </action> <!-- 更新 --> <action name="update" class="com.zhanggaosong.ssi.action.UserAction" method="update"> <result name="success" type="redirectAction"> <param name="actionName">queryall</param> <param name="namespace">/</param> </result> <result name="error">/error.jsp</result> </action> <!-- 删除 --> <action name="delete" class="com.zhanggaosong.ssi.action.UserAction" method="delete"> <result name="success" type="redirectAction"> <param name="actionName">queryall</param> <param name="namespace">/</param> </result> <result name="error"> /error.jsp </result> </action> <!-- 查询所有 --> <action name="queryall" class="com.zhanggaosong.ssi.action.UserAction" method="queryall"> <result name="success">${pageContext.request.contextPath}/pages/manage.jsp</result> <result name="input">/123.jsp</result> </action> </package></struts>7.4 jdbc.properties 文件
7.4.1 jdbc.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ibatisjdbc.username=rootjdbc.password=1234567.5 struts.xml 文件
7.5.1 struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
<include file="struts/user-struts.xml" /></struts>7.6 test.sql 数据库脚本
7.6.1 test.sql
drop database if exists ibatis;
create database ibatis;use ibatis;CREATE TABLE user ( id int auto_increment, name varchar(255) NOT NULL, password varchar(255) NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;7.7 web.xml 文件
7.7.1 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/applicationContext.xml</param-value> </context-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>8.前台页面
8.1 index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=cn-gb"><link href="css/style.css" rel="stylesheet" type="text/css"><title>SSI整合</title><script type="text/javascript"> function userAction() { var d = document.forms[0]; d.action = "login"; d.submit; }</script><style type="text/css"> .errorMessage { font-size: 12px; color: red;}</style></head><body>
<center> <h2>Struts2-Spring-Ibatis 用户登录</h2> </center> <center> <s:actionmessage /> <!-- 用来提示用户名或密码错误 --> <font color="red"> ${requestScope.error}</font> <s:form method="post"> <table> <tr> <td><s:textfield label="用户名" name="user.name" /></td> </tr> <tr> <td><s:password label="密码" name="user.password" /></td> </tr> <tr align="center"> <td colspan="2"> <input type="image" src="images/tj.gif" οnclick="userAction()" /> <input type="image" src="images/cz.gif" οnclick="" /> </td> </tr> </table> </s:form> <a href="pages/register.jsp">注册</a> </center></body></html>8.2 manage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk"><link href="css/style.css" rel="stylesheet" type="text/css"><title>Insert title here</title><script type="text/javascript">var link;function userAction(link) { var d= document.forms[0]; d.action=link; d.submit;}function userActionDel(link){
if(window.confirm("确认删除吗?")){ var d= document.forms[0]; d.action=link; d.submit; }else{ }}</script></head><body><div align="center"><form action="#" method="post"><table border="1" width="80%"> <tr> <th>用户名</th> <th>密码</th> <th>修改</th> <th>删除</th> </tr> <s:iterator value="#request.userList" id="user"> <tr> <td> <s:property value="#user.name"/> </td> <td> <s:property value="#user.password"/> </td> <td> <input type="image" src="images/modify_page.png" onClick="userAction('pages/update.jsp?userName=<s:property value="#user.name" />&password=<s:property value="#user.password" />')" /> </td> <td> <input type="image" src="images/delete_page.png" οnclick="userActionDel('delete?name=<s:property value="#user.name" />')" /> </td> </tr> </s:iterator></table></form></div></body></html>8.3 register.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=cn-gb"><link href="css/style.css" rel="stylesheet" type="text/css"><title>SSI整合</title><script type="text/javascript"> function userAction() { var d = document.forms[0]; d.action = "register"; d.submit; }</script><style type="text/css"> .errorMessage { font-size: 12px; color: red;}</style></head><body> <center> <h2>用户注册</h2> </center> <center> <font color="red"> ${requestScope.addUserName}</font> <s:form method="post"> <table> <tr> <td><s:textfield label="用户名" name="user.name" /></td> </tr> <tr> <td><s:password label="密码" name="user.password" /></td> </tr> <tr align="center"> <td colspan="2"> <input type="image" src="../images/tj.gif" οnclick="userAction()" /> <input type="image" src="../images/cz.gif" οnclick="" /> </td> </tr> </table> </s:form> </center></body></html>8.4 update.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=cn-gb"><link href="css/style.css" rel="stylesheet" type="text/css"><title>SSI整合</title><script type="text/javascript"> function userAction(){ var d = document.forms[0]; d.action = "update"; d.submit; }</script></head>
<body>
<center> <h2>用户修改</h2> </center> <% String username = request.getParameter("userName"); String password = request.getParameter("password"); %> <form method="post"> <table align="center"> <tr> <td>用户名:<input readonly type="text" name="user.name" value="<%=username%>" /></td> </tr> <tr> <td>密 码:<input type="text" name="user.password" value="<%=password%>" /></td> </tr> <tr> <td align="center"> <input type="image" src="${pageContext.request.contextPath}/images/tj.gif" οnclick="userAction()" /> </td> </tr> </table> </form></body></html>8.5 success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <head> <title>用户登录成功</title> <script type="text/javascript"> function userAction(){ var d = document.forms[0]; d.action = "queryall"; d.submit; } </script> </head> <body> <h2 align="center">用户登录成功</h2> <font color="red">${sessionScope.user.name}</font> 欢迎您 <br/><form action=""> <input type="image" src="images/dl.gif" οnclick="userAction();"/> </form> </body></html>