救救孩子吧,快瘋了
tomcat7.0.105
struts2.2.3.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/j2ee"
xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.4">
<filter>
<!-- Filter名稱 -->
<filter-name>struts2</filter-name>
<!--Filter入口 -->
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<!-- Filter名稱 -->
<filter-name>struts2</filter-name>
<!-- 截獲的所有URL-->
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<!-- 開始頁面 -->
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Congfiguration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!--指定struts.xml檔案的根元素-->
<struts>
<!--配置包,包名為default,
該包繼承了Struts 2框架的默認包struts-default-->
<package name="default" namespace="/" extends="struts-default">
<!--定義名為hello的Action,該Action的處理類為com.action.TestAction,
并映射到success.jsp頁面-->
<action name="hello" class="com.action.TestAction">
<result>/success.jsp</result>
</action>
</package>
</struts>
struts.propertoes
<struts.i18n.encoding value="https://bbs.csdn.net/topics/UTF-8"/>
index.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= ">
<title>Insert title here</title>
</head>
<body>
<!--a標簽-->
<s:a action="hello">hello</s:a>
</body>
</html>
success.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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<body>
<!--輸出helo值-->
<s:property value="https://bbs.csdn.net/topics/helo"/>
</body>
</body>
</html>
TestAction.java
package com.action;
import com.opensymphony.xwork2.ActionSupport;
public class TestAction extends ActionSupport{
private static final long serialVersionUID=1L;
private String helo; //Action屬性
//getter方法
public String getHelo() {
return helo;
}
//setter方法
public void setHelo(String helo) {
this.helo = helo;
}
//重載execute()方法
public String execute() throws Exception {
helo="hello,world";
return SUCCESS;
}
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/100728.html
標籤:XML/XSL
上一篇:HTML骨架
