巴索罗米·杰

I hear – and I forget; I see – and I remember; I do – and I understand!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 


 


 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 'login.jsp' starting page</title>
13 
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 
23     </head>
24 
25     <body>
26         <center>
27             <form name="login" action="#" method="post">
28                 <table>
29 
30                     <tr>
31                         <td>
32                             用户名:
33                         </td>
34                         <td>
35                             <input type="text" name="username" />
36                         </td>
37                     </tr>
38                     <tr>
39                         <td>
40                             密码:
41                         </td>
42                         <td>
43                             <input type="password" name="password" />
44                         </td>
45                     </tr>
46                     <tr>
47                         <td>
48                             验证码:
49                         </td>
50                         <td>
51                             <input type="text" name="verfiy">
52                         </td>
53                         <td>
54                             <input />
55                         </td>
56                     </tr>
57                     <tr>
58                         <td>
59                             <input type="submit" value="提交" />
60                         </td>
61                         <td>
62                             <input type="submit" value="注册">
63                         </td>
64                     </tr>
65                 </table>
66             </form>
67         </center>
68     </body>
69 </html>
login.jsp
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
 3 <tiles-definitions>
 4     <definition name="adminTiles" template="/WEB-INF/commons/layout.jsp">
 5         <put-attribute name="CONTENT" value="/WEB-INF/commons/content.jsp" />
 6         <put-attribute name="FOOTER" value="/WEB-INF/commons/footer.jsp" />
 7         <put-attribute name="SIDERBAR" value="/WEB-INF/commons/siderbar.jsp" />
 8         <put-attribute name="WELCOME" value="/WEB-INF/commons/welcome.jsp" />
 9     </definition>
10 </tiles-definitions>
tiles.xml
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
 3  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">
 4  <filter>
 5   <filter-name>struts2</filter-name>
 6   <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 7  </filter>
 8  
 9  <filter-mapping>
10   <filter-name>struts2</filter-name>
11   <url-pattern>/*</url-pattern>
12  </filter-mapping>
13  <welcome-file-list>
14   <welcome-file>login.jsp</welcome-file>
15  </welcome-file-list>
16  <login-config>
17   <auth-method>BASIC</auth-method>
18  </login-config>
19  <listener>
20      <listener-class>
21          org.apache.struts2.tiles.StrutsTilesListener
22      </listener-class>
23  </listener>
24 </web-app>
web.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
3 <struts>
4     <package name="admin" namespace="/" extends="tiles-default">
5         <action name="admin">
6             <result type="tiles">adminTiles</result>
7         </action>
8     </package>
9 </struts>    
struts.xml

以上四部分为struts2中tiles主要核心配制,用于控制布局及关联。

 

posted on 2013-05-28 01:20  SeeGo  阅读(185)  评论(0编辑  收藏  举报