log4j.properties
login.jsp
web.xml
log4j.rootLogger=info,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
log4j.logger.com.wehave=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=info
log4j.logger.java.sql.PreparedStatement=info
log4j.logger.java.sql.ResultSet=info
log4j.logger.javax.sql=info
login.jsp
<%@ page language="java" pageEncoding="gb2312"%>
<%
String path = request.getParameter("info");
if(null==path)path="";
else path="该用户名已经存在";
%>
<!-- 导入struts2标签库 -->
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>用户登录</title>
</head>
<body>
<center>
<div id="login">
<s:form action="loginAction">
<%= path %>
<s:textfield label="用户名" name="userName"></s:textfield>
<s:password label="密码" name="userPassword"></s:password>
<s:submit value="登录"></s:submit>
</s:form>
</div>
</center>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>