/**
  * @RequestMapping(value='/sample/index.json')
  */
 public function indexJson(HttpServletRequest $req, HttpServletResponse $res)
 {
     // 파라미터 획득
     $email = $this->getRequestParam('email');
     // 뷰로 email 값 전달
     $model = new ModelMap();
     $model->addAttribute('email', $email);
     return new ModelAndView('JSONView', $model);
 }
Esempio n. 2
0
 public function display(HttpServletRequest &$req, HttpServletResponse &$res, ModelMap $model = null)
 {
     $arr = $model->getAttributes();
     // cross domain
     $res->setHeader('Access-Control', 'allow <*>');
     $res->setHeader('Access-Control-Allow-Origin', '*');
     $res->setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
     $res->setHeader('Access-Control-Allow-Credentials', 'true');
     $this->sendResponseHeader($req, $res);
     $res->getWriter()->print_($this->jsonEncode($arr));
     return true;
 }
 public function __construct($param, &$ex)
 {
     if (array_key_exists('contextConfigLocation', $param)) {
         $this->loadContextConfig($param['contextConfigLocation']);
     }
     $this->_ex = $ex;
     $this->request = new HttpServletRequest();
     $this->response = new HttpServletResponse();
     $findIt = false;
     $model = new ModelMap();
     $model->addAttribute('exception', $ex);
     if (sizeof($this->_exceptionMap) > 0) {
         foreach ($this->_exceptionMap as $exObj) {
             $exMap = $exObj->getExceptionMappings();
             foreach ($exMap as $exClassName => $viewTemplate) {
                 eval("\$tarEx = new \\" . $this->getPhpNamespaceByDotNotation($exClassName) . ';');
                 if ($ex instanceof $tarEx) {
                     foreach ($this->_viewResolverMap as $order => $viewResolver) {
                         if ($viewResolver->display($this->request, $this->response, $viewTemplate, $model)) {
                             $findIt = true;
                             break 3;
                         }
                     }
                 }
             }
         }
     }
     if (!$findIt) {
         if (sizeof($this->_exceptionMap) > 0) {
             foreach ($this->_exceptionMap as $exObj) {
                 $viewTemplate = $exObj->getDefaultErrorView();
                 foreach ($this->_viewResolverMap as $order => $viewResolver) {
                     if ($viewResolver->display($this->request, $this->response, $viewTemplate, $model)) {
                         $findIt = true;
                         break 2;
                     }
                 }
             }
         }
         if (!$findIt) {
             $this->displayError($ex);
         }
     }
 }