您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> 大家都是怎么学习struts2的?

大家都是怎么学习struts2的?

来源:网络整理     时间:2016/8/10 19:14:22     关键词:

关于网友提出的“ 大家都是怎么学习struts2的?”问题疑问,本网通过在网上对“ 大家都是怎么学习struts2的?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 大家都是怎么学习struts2的?
描述:

  感觉都不知道从哪里下手,下了个英文的api,自带的doc文件也看了,也是英文的,有点头大,不好怎么用,今天搞了老半天就搞出个登陆的来,大家有什么好的jrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播,给我介绍一下吧
还有那种如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, Validateable{
    
    private Order model = new Order();
    private String id;
    private Collection 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 in action 我入门struts2的jrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播。只看了一点jrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播然后 就开始做项目了 逐渐的就熟悉了

解决方案2:

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

解决方案3:

struts-2.1.6\lib\xwork-2.1.2.jar


以上介绍了“ 大家都是怎么学习struts2的?”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3195780.html

相关图片

相关文章