大家都是怎么学习struts2的?

zhangye0807 2009-10-25 07:22:14
感觉都不知道从哪里下手,下了个英文的api,自带的doc文件也看了,也是英文的,有点头大,不好怎么用,今天搞了老半天就搞出个登陆的来,大家有什么好的教程,给我介绍一下吧

还有那种如com.opensymphony.xwork2.ModelDriven形式的包在哪里啊?我找遍了struts整个包都没有找着!!

import java.util.Collection;

import org.apache.struts2.dispatcher.ServletActionRedirectResult;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Namespaces;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.InterceptorRef;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;

@Results({
@Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
})
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable{

private Order model = new Order();
private String id;
private Collection<Order> list;
private OrdersService ordersService = new OrdersService();

// GET /orders/1
public HttpHeaders show() {
return new DefaultHttpHeaders("show");
}

// GET /orders
public HttpHeaders index() {
list = ordersService.getAll();
return new DefaultHttpHeaders("index")
.disableCaching();
}

// GET /orders/1/edit
public String edit() {
return "edit";
}

// GET /orders/new
public String editNew() {
model = new Order();
return "editNew";
}

// GET /orders/1/deleteConfirm
public String deleteConfirm() {
return "deleteConfirm";
}

// DELETE /orders/1
public String destroy() {
ordersService.remove(id);
addActionMessage("Order removed successfully");
return "success";
}

// POST /orders
public HttpHeaders create() {
ordersService.save(model);
addActionMessage("New order created successfully");
return new DefaultHttpHeaders("success")
.setLocationId(model.getId());
}

// PUT /orders/1
public String update() {
ordersService.save(model);
addActionMessage("Order updated successfully");
return "success";
}

public void validate() {
if (model.getClientName() == null || model.getClientName().length() ==0) {
addFieldError("clientName", "The client name is empty");
}
}

public void setId(String id) {
if (id != null) {
this.model = ordersService.get(id);
}
this.id = id;
}

public Object getModel() {
return (list != null ? list : model);
}

}
...全文
362 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzc_zxy 2009-10-26
  • 打赏
  • 举报
回复
struts2 in action 我入门struts2的教程。只看了一点教程然后 就开始做项目了 逐渐的就熟悉了
blliy117 2009-10-25
  • 打赏
  • 举报
回复
struts2我就买了一本书

孙鑫的
struts2深入详解
yate123 2009-10-25
  • 打赏
  • 举报
回复
就说按书的学,再做几个例子就可以了啊,把其他做过的东西用struts2再做一遍就可以了
haojia0716 2009-10-25
  • 打赏
  • 举报
回复
struts-2.1.6\lib\xwork-2.1.2.jar
zhangye0807 2009-10-25
  • 打赏
  • 举报
回复
重点回答下我的第二个问题吧,就那些个包在哪,我找老半天了!
cooler4k 2009-10-25
  • 打赏
  • 举报
回复
去下个教程 《STRUTS2 权威指南》看看吧,驴子上有,
驴子上也有视频教程
老张-AI 2009-10-25
  • 打赏
  • 举报
回复

还是用struts1.2的飘过

67,543

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧