package com.cloudcross.ssp.web;

import org.apache.commons.lang.ArrayUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cloudcross.ssp.base.web.SimpleController;
import com.cloudcross.ssp.common.error.NotFoundException;
import com.cloudcross.ssp.common.utils.LangUtil;

/**
 *	异常页面控制器。
 * 
 * @author qaohao
 */
@Controller
@RequestMapping("/errors")
public class ErrorsController extends SimpleController {
	public static final String[] ERROR_CODES={"404", "403", "500"};
	
	/**
	 * @return 返回对应错误提示页面。
	 */
	@RequestMapping("/{errorCode}")
	public String doError(@PathVariable String errorCode) {
		if(ArrayUtils.indexOf(ERROR_CODES, LangUtil.replaceNull(errorCode))<0) {
			throw new NotFoundException("请求/errors/"+errorCode+"找不到。");
		}
		return page(errorCode);
	}
	
}
