Several interfaces that need to be implemented by the action layer in SSH

Source: Internet
Author: User

Mall SSH Schema Action layer

On the code first, the implementation of Modeldriven, can be in the JSP value of the family class name, such as User.Name, can be written directly into the name

Requestaware, Sessionaware, Applicationaware can be directly in three of the built-in objects in some data, map format

Package com.zzu.shopol.action;

Import Java.lang.reflect.ParameterizedType;
Import Java.util.HashMap;
Import Java.util.Map;

Import Org.apache.struts2.interceptor.ApplicationAware;
Import Org.apache.struts2.interceptor.RequestAware;
Import Org.apache.struts2.interceptor.SessionAware;

Import Com.opensymphony.xwork2.ActionSupport;
Import Com.opensymphony.xwork2.ModelDriven;
Import Com.zzu.shopol.pojo.Account;
Import Com.zzu.shopol.service.AccountService;
Import Com.zzu.shopol.service.CategoryService;
Import Com.zzu.shopol.service.ForderService;
Import Com.zzu.shopol.service.GoodsService;
Import Com.zzu.shopol.service.SorderService;
Import Com.zzu.shopol.util.FileUploadUtil;


@SuppressWarnings ("All")
public class Baseaction<t> extends Actionsupport implements MODELDRIVEN<T>
Requestaware, Sessionaware, Applicationaware {

/**
*
*/
Protected map<string,object> jsonmap=new hashmap<string,object> ();

Private static final long serialversionuid = -7030960600300720776l;

protected T model =null;

Protected Map<string, object> session = NULL;

Protected Map<string, object> application = null;

Protected Map<string, object> request = null;

protected Accountservice accountservice = null;

protected Categoryservice categoryservice = null;

protected Goodsservice goodsservice = null;

protected Fileuploadutil fileuploadutil = null;

protected Sorderservice sorderservice = null;

protected Forderservice Forderservice =null;

Gets the immediate parent class of the subclass
Baseaction () {

try {
Parameterizedtype type = (Parameterizedtype) this.getclass (). Getgenericsuperclass ();
Class Clazz = (Class) type.getactualtypearguments () [0];
Model = (T) clazz.newinstance ();
} catch (Exception e) {
throw new RuntimeException (e);
}

}

This method has an interceptor call after the action is created, so the order of execution after the method is constructed
Public T Getmodel () {

return model;
}



Public Forderservice Getforderservice () {
return forderservice;
}

public void Setforderservice (Forderservice forderservice) {
This.forderservice = Forderservice;
}

Public Sorderservice Getsorderservice () {
return sorderservice;
}

public void Setsorderservice (Sorderservice sorderservice) {
This.sorderservice = Sorderservice;
}

Public Fileuploadutil Getfileuploadutil () {
return fileuploadutil;
}

public void Setfileuploadutil (Fileuploadutil fileuploadutil) {
This.fileuploadutil = Fileuploadutil;
}

public void Setrequest (map<string, object> request) {

This.request = Request;
}

public void Setapplication (map<string, object> application) {

this.application = Application;
}

public void Setsession (Map<string, object> session) {

This.session = session;
}

Public Accountservice Getaccountservice () {
return accountservice;
}

public void Setaccountservice (Accountservice accountservice) {
This.accountservice = Accountservice;
}

Public Categoryservice Getcategoryservice () {
return categoryservice;
}

public void Setcategoryservice (Categoryservice categoryservice) {
This.categoryservice = Categoryservice;
}

Public Goodsservice Getgoodsservice () {
return goodsservice;
}

public void Setgoodsservice (Goodsservice goodsservice) {
This.goodsservice = Goodsservice;
}

Public map<string, Object> Getjsonmap () {
return jsonmap;
}

public void Setjsonmap (map<string, object> jsonmap) {
This.jsonmap = Jsonmap;
}

Public map<string, Object> getsession () {
return session;
}

Public map<string, Object> getrequest () {
return request;
}

public void Setmodel (T model) {
This.model = model;
}







}

Several interfaces that need to be implemented by the action layer in SSH

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.