fromJSON(TypeReference) 추가

master
mjkhan21 11 months ago
parent 61cf53c4bb
commit 6523eb8440

@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.AbstractComponent;
@ -92,6 +93,20 @@ public abstract class AbstractController extends AbstractComponent {
} }
} }
/**JSON typeRef .
* @param <T>
* @param content JSON
* @param typeRef TypeReference
* @return typeRef
*/
protected <T> T fromJson(String content, TypeReference<T> typeRef) {
try {
return objectMapper.readValue(content, typeRef);
} catch (Exception e) {
throw applicationException(e);
}
}
/**ModelAndView list .<br /> /**ModelAndView list .<br />
* <code>setCollectionInfo(mav, list, "obj")</code> * <code>setCollectionInfo(mav, list, "obj")</code>
* mav . * mav .

Loading…
Cancel
Save