MyEclipse8.5配置Struts2.1步骤

步骤一:创建新的Web Project



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



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






步骤四:创建一个Action
Java代码 复制代码  收藏代码
  1. package com.test.action;   
  2.   
  3. import com.opensymphony.xwork2.ActionSupport;   
  4.   
  5. @SuppressWarnings("serial")   
  6. public class TestAction extends ActionSupport {   
  7.        
  8.     @Override  
  9.     public String execute() throws Exception {   
  10.        System.out.println("Message: TestAction!");   
  11.        return SUCCESS;   
  12.     }   
  13. }  
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文件
Html代码 复制代码  收藏代码
  1. <body>  
  2.     <a href="<%=path%>/test.action">test</a>  
  3. </body>  
	<body>
		<a href="<%=path%>/test.action">test</a>
	</body>


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


步骤七:配置struts.xml文件
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.     <include file="struts-default.xml">include</include>  
  5.     <package name="Test" namespace="/" extends="struts-default">  
  6.         <action name="test" class="org.test.action.TestAction">  
  7.             <result name="success">/welcome.jsp</result>  
  8.         </action>  
  9.     </package>  
  10. </struts>     
<?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>    
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值