package com.trs.project.openweb;

import com.trs.project.model.ObjectData;
import org.springframework.stereotype.Controller;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;

@Controller
public class BaseController {
    /**
     * new PageData对象
     * @return
     */
    public ObjectData getData() {
        return new ObjectData(this.getRequest());
    }
    /**
     * 得到request对象
     * @return
     */
    public HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes()).getRequest();
        return request;
    }
}
