Struts入门教程

本文是一篇关于Struts入门的教程,介绍了如何在MyEclipse中创建Web Project并安装Struts框架,包括加载struts.xml配置文件、导入所需JAR包。同时,文章详细讨论了在使用过程中遇到的HTTP Status 404错误和JVM_Bind错误的解决办法,提供了相应的解决方案链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.打开mycelipse,创建Web Project

2.安装测试Struts框架。

http://struts.apache.org/download.cgi#struts23241

下载struts-2.3.24.1-all.zip ,或struts-2.3.24.1-apps.zip。找到struts2-blank.war。

用RAR压缩,

2.1 加载安装Struts

找到web.xml,copy到Web-inf目录下。

2.2 加载Strus2需要导入的JAR包

找到struts2-core-2.3.,copy到Web-inf目录LIb目录下。

2.3 struts配置文件部署

src\struts.xml,copy到src.struts.xml,删除标签<struts>下的所有内容。

tomcat启动时,没有找到类,则是对应在Struts2事例文件中的LIB中找到包。

我的遇到的问题:以下两个问题。

下午 org.apache.struts2.dispatcher.Dispatcher error

http://blog.youkuaiyun.com/weibkreuz/article/details/45061349

http://bbs.youkuaiyun.com/topics/390724260


3.使用Struts框架,增加Helloworld

package com.bjecss.Hello;


public class HelloWorld {
private String msg;


public String execute(){
this.setMessage("bigsnow is first.");
return "success";
}


public String getMessage() {
return msg;
}


public void setMessage(String message) {
this.msg = message;
}
}


 <package name="default" namespace="/" extends="struts-default">
  <action name="hello" class="com.bjecss.Hello.HelloWorld" method="execute">
  <result name="success">/WEB-INF/page/hello.jsp</result>
  </action>
 </package>

遇到的问题:jsp页面地址写错了,以下错误提示。

HTTP Status 404 - /webStrustss/WebRoot/WEB-INF/hello.jsp

description The requested resource is not available.

"WebRoot/WEB-INF/page/hello.jsp"需要去掉WebRoot主目录。

 大4

4.myeclipse的自带浏览器在加载时关闭,报错。重新打开myEclipse,导致JAVA

Address already in use: JVM_Bind<null>:8080错误的解决办法 

解决方案:http://blog.youkuaiyun.com/mixiuali/article/details/7981532。可以 用。

设置默认的myEclipse浏览器:http://jingyan.baidu.com/article/c85b7a640208d0003bac95ab.html


源代码下载:http://download.youkuaiyun.com/detail/leejianxue/9380753





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值