在MyEclipse 8.5 中搭建Struts2.1

步骤一:创建新的Web Project

在MyEclipse 8.5 中搭建Struts2.1

步骤二:新项目上右击-->MyEclipse-->Add Struts Capabilities...

在MyEclipse 8.5 中搭建Struts2.1

步骤三:选择Struts版本为Struts 2.1

在MyEclipse 8.5 中搭建Struts2.1

在MyEclipse 8.5 中搭建Struts2.1


步骤四:创建一个Action
package com.test.action;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class TestAction extends ActionSupport {
	
	@Override
    public String execute() throws Exception {
       System.out.println("Message: TestAction!");
       return SUCCESS;
    }
}


步骤五:修改index.jsp文件
	<body>
		<a href="<%=path%>/test.action">test</a>
	</body>


步骤六:创建welcome.jsp文件
(文件中的内容自行决定哈)


步骤七:配置struts.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
	<include file="struts-default.xml">include</include>
	<package name="Test" namespace="/" extends="struts-default">
		<action name="test" class="org.test.action.TestAction">
			<result name="success">/welcome.jsp</result>
		</action>
	</package>
</struts>    


你可能感兴趣的:(apache,jsp,xml,struts,MyEclipse)