項目網站:www.aikan66.com
遊戲網站:www.aikan66.com
圖片網站:www.aikan66.com
書籍網站:www.aikan66.com
學習網站:www.aikan66.com
Java網站:www.aikan66.com
iOS網站:www.aikan66.comhtml
----java
說明web08項目更加詳細14.1web
----apache
一、新建web項目,名字webjwrm02-struts,拷貝Struts2包到lib,配置web.xml.(詳見web08)jsp
二、配置Struts學習
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <!-- 聲明包 --> <package name="myPackage" extends="struts-default"> <!-- 定義action --> <action name="first"> <!-- 定義處理成功後的映射頁面 --> <result>/first.jsp</result> </action> </package> </struts>
三、index.jsp修改成網站
<%@ 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> <a href="first.action">第一個Struts程序</a> </body> </html>
四、添加first.jspui
<%@ 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 'first.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> 第一個Struts程序! <br> </body> </html>
五、部署項目,訪問地址spa
http://localhost:8080/jwrm02-struts/index.jsp
點擊「第一個Struts程序」,結果(注意感嘆號)
----
完畢
struts2配置