View와 ViewResolver에 대한 재설계 반영 및 예외처리 로직 추가
This commit is contained in:
@@ -5,18 +5,24 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
|
|||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import com.terry.xplatform.config.xplatform.web.XplatformView;
|
||||||
|
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class GlobalExceptionHandler {
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
@ExceptionHandler(value={DataAccessException.class})
|
@ExceptionHandler(value={DataAccessException.class})
|
||||||
public ModelAndView processDataAccessException(DataAccessException ex){
|
public XplatformView processDataAccessException(DataAccessException ex){
|
||||||
|
/*
|
||||||
ModelAndView modelAndView = new ModelAndView();
|
ModelAndView modelAndView = new ModelAndView();
|
||||||
modelAndView.addObject("ErrorCode", "-1");
|
modelAndView.addObject("ErrorCode", "-1");
|
||||||
modelAndView.addObject("ErrorMsg", ex.getMessage());
|
modelAndView.addObject("ErrorMsg", ex.getMessage());
|
||||||
modelAndView.setViewName("errorView");
|
modelAndView.setViewName("errorView");
|
||||||
return modelAndView;
|
return modelAndView;
|
||||||
|
*/
|
||||||
|
XplatformView xplatformView = new XplatformView("30", ex.getMessage());
|
||||||
|
return xplatformView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(value={Exception.class})
|
@ExceptionHandler(value={Exception.class})
|
||||||
public ModelAndView processException(Exception ex){
|
public ModelAndView processException(Exception ex){
|
||||||
ModelAndView modelAndView = new ModelAndView();
|
ModelAndView modelAndView = new ModelAndView();
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ package com.terry.xplatform.config.xplatform;
|
|||||||
|
|
||||||
import com.tobesoft.xplatform.tx.PlatformType;
|
import com.tobesoft.xplatform.tx.PlatformType;
|
||||||
|
|
||||||
public class XplatformConstants implements PlatformType {
|
public interface XplatformConstants extends PlatformType {
|
||||||
public static final String CONTENT_TYPE_CSV = "csv";
|
public static final String CONTENT_TYPE_CSV = "csv";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,9 @@ import java.util.Map.Entry;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.validation.BeanPropertyBindingResult;
|
import org.springframework.validation.BeanPropertyBindingResult;
|
||||||
|
import org.springframework.web.servlet.View;
|
||||||
import org.springframework.web.servlet.support.RequestContext;
|
import org.springframework.web.servlet.support.RequestContext;
|
||||||
import org.springframework.web.servlet.view.AbstractTemplateView;
|
|
||||||
|
|
||||||
import com.terry.xplatform.config.utils.XplatformReflectionUtils;
|
import com.terry.xplatform.config.utils.XplatformReflectionUtils;
|
||||||
import com.terry.xplatform.config.xplatform.XplatformConstants;
|
import com.terry.xplatform.config.xplatform.XplatformConstants;
|
||||||
@@ -27,103 +26,111 @@ import com.tobesoft.xplatform.data.VariableList;
|
|||||||
import com.tobesoft.xplatform.data.datatype.PlatformDataType;
|
import com.tobesoft.xplatform.data.datatype.PlatformDataType;
|
||||||
import com.tobesoft.xplatform.tx.HttpPlatformResponse;
|
import com.tobesoft.xplatform.tx.HttpPlatformResponse;
|
||||||
|
|
||||||
public class XplatformView extends AbstractTemplateView {
|
public class XplatformView implements View {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Xplatform의 작업결과가 성공적이었을때의 ErrorCode 값을 설정한다
|
* Xplatform의 작업결과가 성공적이었을때의 ErrorCode 값을 설정한다
|
||||||
*/
|
*/
|
||||||
private final String ERROR_CODE_VALUE;
|
private final String ERROR_CODE_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Xplatform의 작업결과가 성공적이었을때의 ErrorMsg 값을 설정한다
|
* Xplatform의 작업결과가 성공적이었을때의 ErrorMsg 값을 설정한다
|
||||||
*/
|
*/
|
||||||
private final String ERROR_MSG_VALUE;
|
private final String ERROR_MSG_VALUE;
|
||||||
|
|
||||||
public XplatformView() {
|
public XplatformView() {
|
||||||
this.ERROR_CODE_VALUE = "0";
|
this.ERROR_CODE_VALUE = "0";
|
||||||
this.ERROR_MSG_VALUE = "";
|
this.ERROR_MSG_VALUE = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public XplatformView(String errorCodeValue, String errorMsgValue) {
|
public XplatformView(String errorCodeValue, String errorMsgValue) {
|
||||||
this.ERROR_CODE_VALUE = errorCodeValue;
|
this.ERROR_CODE_VALUE = errorCodeValue;
|
||||||
this.ERROR_MSG_VALUE = errorMsgValue;
|
this.ERROR_MSG_VALUE = errorMsgValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
public String getContentType() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
String contentType = StringUtils.hasText((String)model.get("contentType")) ? (String)model.get("contentType") : XplatformConstants.CONTENT_TYPE_XML;
|
return null;
|
||||||
model.remove("contentType");
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws Exception {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
String contentType = request.getHeader("Content-Type").startsWith("text/xml;") ? XplatformConstants.CONTENT_TYPE_XML
|
||||||
|
: request.getHeader("Content-Type");
|
||||||
|
|
||||||
if(contentType == XplatformConstants.CONTENT_TYPE_XML) {
|
if(contentType == XplatformConstants.CONTENT_TYPE_XML) {
|
||||||
VariableList variableList = new VariableList();
|
VariableList variableList = new VariableList();
|
||||||
DataSetList dataSetList = new DataSetList();
|
DataSetList dataSetList = new DataSetList();
|
||||||
HttpPlatformResponse httpPlatformResponse = new HttpPlatformResponse(httpServletResponse, XplatformConstants.CONTENT_TYPE_XML);
|
HttpPlatformResponse httpPlatformResponse = new HttpPlatformResponse(response, XplatformConstants.CONTENT_TYPE_XML);
|
||||||
|
|
||||||
for(Entry<String, Object> entry : model.entrySet()) {
|
if(model != null) {
|
||||||
String key = entry.getKey();
|
|
||||||
Object object = entry.getValue();
|
for(Entry<String, ?> entry : model.entrySet()) {
|
||||||
if(object instanceof Collection) {
|
String key = entry.getKey();
|
||||||
@SuppressWarnings("unchecked")
|
Object object = entry.getValue();
|
||||||
DataSet dataSet = makeDataSet(key, (Collection<Object>)object);
|
if(object instanceof Collection) {
|
||||||
dataSetList.add(dataSet);
|
@SuppressWarnings("unchecked")
|
||||||
} else {
|
DataSet dataSet = makeDataSet(key, (Collection<Object>)object);
|
||||||
Variable variable = null;
|
dataSetList.add(dataSet);
|
||||||
if(object instanceof Integer) {
|
} else {
|
||||||
variable = new Variable(key, PlatformDataType.INT, (Integer)object);
|
Variable variable = null;
|
||||||
} else if(object instanceof Long) {
|
if(object instanceof Integer) {
|
||||||
variable = new Variable(key, PlatformDataType.LONG, (Long)object);
|
variable = new Variable(key, PlatformDataType.INT, (Integer)object);
|
||||||
} else if(object instanceof Float) {
|
} else if(object instanceof Long) {
|
||||||
variable = new Variable(key, PlatformDataType.FLOAT, (Float)object);
|
variable = new Variable(key, PlatformDataType.LONG, (Long)object);
|
||||||
} else if(object instanceof Double) {
|
} else if(object instanceof Float) {
|
||||||
variable = new Variable(key, PlatformDataType.DOUBLE, (Double)object);
|
variable = new Variable(key, PlatformDataType.FLOAT, (Float)object);
|
||||||
} else if(object instanceof Date) {
|
} else if(object instanceof Double) {
|
||||||
variable = new Variable(key, PlatformDataType.DATE, (Date)object);
|
variable = new Variable(key, PlatformDataType.DOUBLE, (Double)object);
|
||||||
} else if(object instanceof String){
|
} else if(object instanceof Date) {
|
||||||
variable = new Variable(key, PlatformDataType.STRING, (String)object);
|
variable = new Variable(key, PlatformDataType.DATE, (Date)object);
|
||||||
} else if(object instanceof Variable) {
|
} else if(object instanceof String){
|
||||||
variable = (Variable)object;
|
variable = new Variable(key, PlatformDataType.STRING, (String)object);
|
||||||
} else {
|
} else if(object instanceof Variable) {
|
||||||
// model에 들어있는 클래스 객체중에 DataSet으로 변환할 수 없는 클래스 객체가 들어있는것은 bypass 하게끔 한다
|
variable = (Variable)object;
|
||||||
|
} else {
|
||||||
if(skipDataSet(object)) {
|
// model에 들어있는 클래스 객체중에 DataSet으로 변환할 수 없는 클래스 객체가 들어있는것은 bypass 하게끔 한다
|
||||||
continue;
|
|
||||||
}
|
if(skipDataSet(object)) {
|
||||||
|
continue;
|
||||||
// 객체의 멤버변수들 값을 읽어서 한 행짜리 데이터셋으로 return 하는 방법을 고민해보자
|
}
|
||||||
DataSet dataSet = makeDataSet(key, object);
|
|
||||||
dataSetList.add(dataSet);
|
// 객체의 멤버변수들 값을 읽어서 한 행짜리 데이터셋으로 return 하는 방법을 고민해보자
|
||||||
}
|
DataSet dataSet = makeDataSet(key, object);
|
||||||
if(variable != null) {
|
dataSetList.add(dataSet);
|
||||||
variableList.add(variable);
|
}
|
||||||
}
|
if(variable != null) {
|
||||||
}
|
variableList.add(variable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// XplatformView를 만든다는 것은 그 이전단계까지는 예외없이 진행되었다는 뜻이기 때문에 Xplatform에서 읽어들일변수인 ErrorCode 와 ErrorMsg 변수에 작업이 성공했다는 내용을 설정한다
|
||||||
|
// Controller에서 ErrorCode와 ErrorMsg를 설정한 것이 없으면 XplatformView에서 설정하도록 한다
|
||||||
|
if(!model.containsKey("ErrorCode")) {
|
||||||
|
variableList.add("ErrorCode", ERROR_CODE_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!model.containsKey("ErrorMsg")) {
|
||||||
|
variableList.add("ErrorMsg", ERROR_MSG_VALUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XplatformView를 만든다는 것은 그 이전단계까지는 예외없이 진행되었다는 뜻이기 때문에 Xplatform에서 읽어들일변수인 ErrorCode 와 ErrorMsg 변수에 작업이 성공했다는 내용을 설정한다
|
|
||||||
// Controller에서 ErrorCode와 ErrorMsg를 설정한 것이 없으면 XplatformView에서 설정하도록 한다
|
|
||||||
if(!model.containsKey("ErrorCode")) {
|
|
||||||
variableList.add("ErrorCode", ERROR_CODE_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!model.containsKey("ErrorMsg")) {
|
|
||||||
variableList.add("ErrorMsg", ERROR_MSG_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlatformData platformData = new PlatformData();
|
PlatformData platformData = new PlatformData();
|
||||||
platformData.setVariableList(variableList);
|
platformData.setVariableList(variableList);
|
||||||
platformData.setDataSetList(dataSetList);
|
platformData.setDataSetList(dataSetList);
|
||||||
httpPlatformResponse.setData(platformData);
|
httpPlatformResponse.setData(platformData);
|
||||||
httpPlatformResponse.sendData();
|
httpPlatformResponse.sendData();
|
||||||
|
|
||||||
} else if(contentType == XplatformConstants.CONTENT_TYPE_CSV) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
} else if(contentType == XplatformConstants.CONTENT_TYPE_CSV) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Collection 객체와 DataSet 이름을 파라미터로 받아 해당 객체가 들어있는 DataSet을 return 한다
|
* Collection 객체와 DataSet 이름을 파라미터로 받아 해당 객체가 들어있는 DataSet을 return 한다
|
||||||
* @param dataSetName
|
* @param dataSetName
|
||||||
* @param collection
|
* @param collection
|
||||||
@@ -141,7 +148,7 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
}
|
}
|
||||||
return dataSet;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object 객체와 DataSet 이름을 파라미터로 받아 해당 객체가 들어있는 DataSet을 return 한다
|
* Object 객체와 DataSet 이름을 파라미터로 받아 해당 객체가 들어있는 DataSet을 return 한다
|
||||||
* @param dataSetName
|
* @param dataSetName
|
||||||
@@ -156,7 +163,7 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
addObjectToDataSet(dataSet, object);
|
addObjectToDataSet(dataSet, object);
|
||||||
return dataSet;
|
return dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataSet 객체와 DataSet에 들어갈 객체를 파라미터로 받아 DataSet 객체에 ColumnHeader 정보를 설정한다
|
* DataSet 객체와 DataSet에 들어갈 객체를 파라미터로 받아 DataSet 객체에 ColumnHeader 정보를 설정한다
|
||||||
* @param dataSet
|
* @param dataSet
|
||||||
@@ -168,7 +175,7 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
Map<String, Object> map = (Map<String, Object>) object;
|
Map<String, Object> map = (Map<String, Object>) object;
|
||||||
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
|
|
||||||
if(value instanceof Integer) {
|
if(value instanceof Integer) {
|
||||||
dataSet.addColumn(entry.getKey(), DataTypes.INT);
|
dataSet.addColumn(entry.getKey(), DataTypes.INT);
|
||||||
} else if(value instanceof Long) {
|
} else if(value instanceof Long) {
|
||||||
@@ -205,7 +212,7 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection 객체를 받아 Collection 객체 안에 있는 객체들을 묶어서 하나의 DataSet으로 만들어서 추가한다
|
* Collection 객체를 받아 Collection 객체 안에 있는 객체들을 묶어서 하나의 DataSet으로 만들어서 추가한다
|
||||||
* @param dataSet
|
* @param dataSet
|
||||||
@@ -216,13 +223,13 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
private void addCollectionToDataSet(DataSet dataSet, Collection<Object> collection) throws IllegalArgumentException, IllegalAccessException {
|
private void addCollectionToDataSet(DataSet dataSet, Collection<Object> collection) throws IllegalArgumentException, IllegalAccessException {
|
||||||
Iterator<Object> iterator = collection.iterator();
|
Iterator<Object> iterator = collection.iterator();
|
||||||
// Object value = collection.iterator().next();
|
// Object value = collection.iterator().next();
|
||||||
|
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
Object value = iterator.next();
|
Object value = iterator.next();
|
||||||
addObjectToDataSet(dataSet, value);
|
addObjectToDataSet(dataSet, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object 객체를 받아 DataSet에 추가한다
|
* Object 객체를 받아 DataSet에 추가한다
|
||||||
* @param dataSet 대상이 되는 DataSet
|
* @param dataSet 대상이 되는 DataSet
|
||||||
@@ -232,14 +239,14 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
*/
|
*/
|
||||||
private void addObjectToDataSet(DataSet dataSet, Object object) throws IllegalArgumentException, IllegalAccessException {
|
private void addObjectToDataSet(DataSet dataSet, Object object) throws IllegalArgumentException, IllegalAccessException {
|
||||||
int rowIdx = dataSet.newRow();
|
int rowIdx = dataSet.newRow();
|
||||||
|
|
||||||
if(object instanceof Map) {
|
if(object instanceof Map) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> map = (Map<String, Object>)object;
|
Map<String, Object> map = (Map<String, Object>)object;
|
||||||
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
String columnName = entry.getKey();
|
String columnName = entry.getKey();
|
||||||
Object mapValue = entry.getValue();
|
Object mapValue = entry.getValue();
|
||||||
|
|
||||||
if(mapValue instanceof Integer) {
|
if(mapValue instanceof Integer) {
|
||||||
dataSet.set(rowIdx, columnName, (int)mapValue);
|
dataSet.set(rowIdx, columnName, (int)mapValue);
|
||||||
} else if(mapValue instanceof Long) {
|
} else if(mapValue instanceof Long) {
|
||||||
@@ -258,12 +265,12 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Field> fieldList = XplatformReflectionUtils.getFields(object);
|
List<Field> fieldList = XplatformReflectionUtils.getFields(object);
|
||||||
|
|
||||||
for(Field field : fieldList) {
|
for(Field field : fieldList) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
String columnName = field.getName();
|
String columnName = field.getName();
|
||||||
Class<?> classType = field.getType();
|
Class<?> classType = field.getType();
|
||||||
|
|
||||||
if(classType == int.class ) {
|
if(classType == int.class ) {
|
||||||
dataSet.set(rowIdx, columnName, field.getInt(object));
|
dataSet.set(rowIdx, columnName, field.getInt(object));
|
||||||
} else if(classType == Integer.class) {
|
} else if(classType == Integer.class) {
|
||||||
@@ -271,26 +278,26 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
} else if(classType == long.class) {
|
} else if(classType == long.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.getLong(object));
|
dataSet.set(rowIdx, columnName, field.getLong(object));
|
||||||
} else if(classType == Long.class) {
|
} else if(classType == Long.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Long)field.get(object)).longValue());
|
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Long)field.get(object)).longValue());
|
||||||
} else if(classType == float.class) {
|
} else if(classType == float.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.getFloat(object));
|
dataSet.set(rowIdx, columnName, field.getFloat(object));
|
||||||
} else if(classType == Float.class) {
|
} else if(classType == Float.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Float)field.get(object)).floatValue());
|
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Float)field.get(object)).floatValue());
|
||||||
} else if(classType == double.class) {
|
} else if(classType == double.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.getDouble(object));
|
dataSet.set(rowIdx, columnName, field.getDouble(object));
|
||||||
} else if(classType == Double.class) {
|
} else if(classType == Double.class) {
|
||||||
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Double)field.get(object)).doubleValue());
|
dataSet.set(rowIdx, columnName, field.get(object) == null ? null : ((Double)field.get(object)).doubleValue());
|
||||||
} else if(classType == Date.class) {
|
} else if(classType == Date.class) {
|
||||||
dataSet.set(rowIdx, columnName, (Date)(field.get(object)));
|
dataSet.set(rowIdx, columnName, (Date)(field.get(object)));
|
||||||
} else if(classType == boolean.class || classType == Boolean.class) { // boolean 계열은 String의 valueOf 메소드로 값을 설정한다
|
} else if(classType == boolean.class || classType == Boolean.class) { // boolean 계열은 String의 valueOf 메소드로 값을 설정한다
|
||||||
dataSet.set(rowIdx, columnName, String.valueOf((field.get(object))));
|
dataSet.set(rowIdx, columnName, String.valueOf((field.get(object))));
|
||||||
} else {
|
} else {
|
||||||
dataSet.set(rowIdx, columnName, (String)(field.get(object)));
|
dataSet.set(rowIdx, columnName, (String)(field.get(object)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renderMergedTemplateModel 메소드의 model 파라미터에 있는 객체들 중에 DataSet으로 표현할 수 없는 클래스들이 있다(주로 Spring이 자체적으로 넣어놓은 property bind 등의 클래스)
|
* renderMergedTemplateModel 메소드의 model 파라미터에 있는 객체들 중에 DataSet으로 표현할 수 없는 클래스들이 있다(주로 Spring이 자체적으로 넣어놓은 property bind 등의 클래스)
|
||||||
* model에 있는 객체중 이런 클래스 객체는 DataSet으로의 변환을 제외시킬 목적으로 만든 메소드이며 개발하는 도중에 이런 성격의 클래스가 있으면 classArray 배열에 클래스를 객체에 있는 것중ㅇ
|
* model에 있는 객체중 이런 클래스 객체는 DataSet으로의 변환을 제외시킬 목적으로 만든 메소드이며 개발하는 도중에 이런 성격의 클래스가 있으면 classArray 배열에 클래스를 객체에 있는 것중ㅇ
|
||||||
@@ -299,19 +306,18 @@ public class XplatformView extends AbstractTemplateView {
|
|||||||
*/
|
*/
|
||||||
private boolean skipDataSet(Object object) {
|
private boolean skipDataSet(Object object) {
|
||||||
Class<?> [] classArray = new Class<?>[] {BeanPropertyBindingResult.class, RequestContext.class};
|
Class<?> [] classArray = new Class<?>[] {BeanPropertyBindingResult.class, RequestContext.class};
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
Class<?> objectClass = object.getClass();
|
Class<?> objectClass = object.getClass();
|
||||||
|
|
||||||
for(Class<?> clazz : classArray) {
|
for(Class<?> clazz : classArray) {
|
||||||
if(clazz == objectClass) {
|
if(clazz == objectClass) {
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
package com.terry.xplatform.config.xplatform.web;
|
package com.terry.xplatform.config.xplatform.web;
|
||||||
|
|
||||||
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
|
import java.util.Locale;
|
||||||
import org.springframework.web.servlet.view.AbstractUrlBasedView;
|
|
||||||
|
|
||||||
public class XplatformViewResolver extends AbstractTemplateViewResolver {
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.web.servlet.View;
|
||||||
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
|
|
||||||
@Override
|
public class XplatformViewResolver implements ViewResolver, Ordered {
|
||||||
protected Class getViewClass() {
|
|
||||||
|
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View resolveViewName(String viewName, Locale locale) throws Exception {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return XplatformView.class;
|
XplatformView xplatformView = new XplatformView();
|
||||||
}
|
return xplatformView;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
|
public int getOrder() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
XplatformView view = (XplatformView)super.buildView(viewName);
|
return order;
|
||||||
return view;
|
}
|
||||||
}
|
|
||||||
|
public void setOrder(int order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,20 +17,21 @@ import com.tobesoft.xplatform.data.DataSet;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SampleServiceImpl implements SampleService {
|
public class SampleServiceImpl implements SampleService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SqlSession sqlSession;
|
private SqlSession sqlSession;
|
||||||
|
|
||||||
SampleDAO sampleDAO;
|
SampleDAO sampleDAO;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
sampleDAO = sqlSession.getMapper(SampleDAO.class);
|
sampleDAO = sqlSession.getMapper(SampleDAO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SampleVO> list(SampleDefaultVO sampleDefaultVO) throws DataAccessException {
|
public List<SampleVO> list(SampleDefaultVO sampleDefaultVO) throws DataAccessException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
// throw new DataAccessException("Test DataAccessException Message") {};
|
||||||
List<SampleVO> result = sampleDAO.selectSampleList(sampleDefaultVO);
|
List<SampleVO> result = sampleDAO.selectSampleList(sampleDefaultVO);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -48,7 +49,7 @@ public class SampleServiceImpl implements SampleService {
|
|||||||
case DataSet.ROW_TYPE_UPDATED :
|
case DataSet.ROW_TYPE_UPDATED :
|
||||||
sampleDAO.updateSample(sampleVO);
|
sampleDAO.updateSample(sampleVO);
|
||||||
break;
|
break;
|
||||||
case DataSet.ROW_TYPE_DELETED :
|
case DataSet.ROW_TYPE_DELETED :
|
||||||
sampleDAO.deleteSample(sampleVO.getId());
|
sampleDAO.deleteSample(sampleVO.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -59,15 +60,15 @@ public class SampleServiceImpl implements SampleService {
|
|||||||
sampleDAO.deleteSample(sampleVO.getId());
|
sampleDAO.deleteSample(sampleVO.getId());
|
||||||
sampleDAO.insertSample(sampleVO);
|
sampleDAO.insertSample(sampleVO);
|
||||||
break;
|
break;
|
||||||
case DataSet.ROW_TYPE_DELETED :
|
case DataSet.ROW_TYPE_DELETED :
|
||||||
sampleDAO.deleteSample(sampleVO.getId());
|
sampleDAO.deleteSample(sampleVO.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class SampleController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
SampleService sampleService;
|
SampleService sampleService;
|
||||||
|
|
||||||
@RequestMapping("/egovSampleSelect")
|
@RequestMapping("egovSampleSelect")
|
||||||
public void list(Model model
|
public void list(Model model
|
||||||
, SampleVO sampleVO
|
, SampleVO sampleVO
|
||||||
, @RequestVariable SampleVO requestVariableSampleVO
|
, @RequestVariable SampleVO requestVariableSampleVO
|
||||||
|
|||||||
@@ -23,14 +23,14 @@
|
|||||||
</bean>
|
</bean>
|
||||||
</mvc:argument-resolvers>
|
</mvc:argument-resolvers>
|
||||||
</mvc:annotation-driven>
|
</mvc:annotation-driven>
|
||||||
|
|
||||||
<context:component-scan base-package="com.terry.xplatform">
|
<context:component-scan base-package="com.terry.xplatform">
|
||||||
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
|
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
|
||||||
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
|
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
|
||||||
</context:component-scan>
|
</context:component-scan>
|
||||||
|
|
||||||
<bean id="xplatformViewResolver" class="com.terry.xplatform.config.xplatform.web.XplatformViewResolver">
|
<bean id="xplatformViewResolver" class="com.terry.xplatform.config.xplatform.web.XplatformViewResolver">
|
||||||
<property name="order" value="1" />
|
<property name="order" value="1" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
Reference in New Issue
Block a user