日期:2014-05-17 浏览次数:20663 次
<?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">
<display-name></display-name>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?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>
<!-- 改变url现实的后缀,默认是action -->
<constant name="struts.action.extension" value="xhtml" />
<package name="struts2login" extends="struts-default">
<!-- 这里的Class是由Spring里面制定的ID,如果单独用struts2,则这里是包名+类名 -->
<action name="UserLogin" class="com.greatwqs.action.PersonAction">
<result name="success" >/login_s.jsp</result>
<result name="input">/login.jsp</result>
</action>
</package>
</struts>
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Struts2 Person Login Test</title>
</head>
<body>
<s:form action="UserLogin">
<s:textfield name="per.username" label="username"></s:textfield>
<s:password name="per.password" label="password"></s:password>
<s:submit></s:submit>
</s:form>
</body>
</html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String username = (String)session.getAttribute("user");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>Struts2 Person Login Result</title>
</head>
<body&g