感觉都不知道从哪里下手,下了个英文的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);
    }}

解决方案 »

  1.   

    去下个教程 《STRUTS2 权威指南》看看吧,驴子上有,
    驴子上也有视频教程
      

  2.   

    就说按书的学,再做几个例子就可以了啊,把其他做过的东西用struts2再做一遍就可以了
      

  3.   

    struts2我就买了一本书孙鑫的
    struts2深入详解
      

  4.   

    struts2 in action 我入门struts2的教程。只看了一点教程然后 就开始做项目了 逐渐的就熟悉了