From d8a7bcd8698f6778d76b27fa76bbeaf1aa5ad509 Mon Sep 17 00:00:00 2001 From: datagear Date: Thu, 21 Feb 2019 22:24:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8FreeMarker=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=89=80=E6=9C=89JSP=EF=BC=8C=E4=BB=A5=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E7=94=B1=E4=BA=8EJSP=E7=BC=96=E8=AF=91=E4=B8=8D=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=AF=BC=E8=87=B4=E6=9E=84=E5=BB=BA=E7=9A=84=E9=9B=86?= =?UTF-8?q?=E6=88=90=E8=BD=AF=E4=BB=B6=E5=8C=85=E5=9C=A8JRE8=E5=8F=8A?= =?UTF-8?q?=E4=BB=A5=E4=B8=8A=E7=89=88=E6=9C=AC=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=BF=90=E8=A1=8C=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SchemaServiceImpl.java | 4 +- .../java/org/datagear/model/support/MU.java | 3 + datagear-web/pom.xml | 5 + .../web/controller/AbstractController.java | 43 +++ .../web/controller/ControllerAdvice.java | 102 +++++-- .../web/controller/DataController.java | 192 ++++++++----- .../controller/DriverEntityController.java | 4 +- .../web/controller/ErrorController.java | 16 +- .../controller/GlobalSettingController.java | 5 +- .../web/controller/LoginController.java | 25 ++ .../web/controller/MainController.java | 27 +- .../controller/ResetPasswordController.java | 2 + .../web/controller/SchemaController.java | 2 +- .../SchemaUrlBuilderController.java | 2 +- .../web/controller/UserController.java | 2 +- .../web/freemarker/CustomFreeMarkerView.java | 50 ++++ .../WriteJsonTemplateDirectiveModel.java | 173 ++++++++++++ .../java/org/datagear/web/util/WebUtils.java | 70 +++++ .../src/main/resources/datagear-servlet.xml | 34 +++ .../resources/locales/datagear.properties | 3 + .../src/main/webapp/WEB-INF/changelog.txt | 1 + .../src/main/webapp/WEB-INF/jsp/about.jsp | 57 ---- .../webapp/WEB-INF/jsp/change_theme_data.jsp | 24 -- .../src/main/webapp/WEB-INF/jsp/changelog.jsp | 73 ----- .../webapp/WEB-INF/jsp/data/data_grid.jsp | 167 ------------ .../jsp/data/include/data_jsp_define.jsp | 20 -- .../include/data_page_obj_edit_grid_html.jsp | 36 --- .../src/main/webapp/WEB-INF/jsp/error.jsp | 104 -------- .../webapp/WEB-INF/jsp/global_setting.jsp | 189 ------------- .../WEB-INF/jsp/include/html_doctype.jsp | 13 - .../webapp/WEB-INF/jsp/include/html_head.jsp | 49 ---- .../webapp/WEB-INF/jsp/include/html_logo.jsp | 13 - .../jsp/include/html_title_app_name.jsp | 12 - .../WEB-INF/jsp/include/jsp_ajax_request.jsp | 11 - .../webapp/WEB-INF/jsp/include/jsp_import.jsp | 7 - .../webapp/WEB-INF/jsp/include/jsp_jstl.jsp | 11 - .../include/jsp_method_get_string_value.jsp | 24 -- .../jsp/include/jsp_method_write_json.jsp | 35 --- .../WEB-INF/jsp/include/jsp_page_id.jsp | 11 - .../jsp/include/jsp_spring_context.jsp | 11 - .../WEB-INF/jsp/include/page_obj_form.jsp | 23 -- .../src/main/webapp/WEB-INF/jsp/login.jsp | 133 --------- .../webapp/WEB-INF/jsp/register_success.jsp | 38 --- .../webapp/WEB-INF/jsp/reset_password.jsp | 252 ------------------ .../jsp/reset_password_request_history.jsp | 87 ------ .../webapp/WEB-INF/jsp/schema_url_builder.jsp | 104 -------- .../webapp/WEB-INF/jsp/user/user_form.jsp | 176 ------------ .../webapp/WEB-INF/jsp/user/user_grid.jsp | 200 -------------- .../src/main/webapp/WEB-INF/view/about.ftl | 48 ++++ .../webapp/WEB-INF/view/change_theme_data.ftl | 18 ++ .../main/webapp/WEB-INF/view/changelog.ftl | 64 +++++ .../data_form.jsp => view/data/data_form.ftl} | 90 +++---- .../webapp/WEB-INF/view/data/data_grid.ftl | 157 +++++++++++ .../data/data_prop_value_form.ftl} | 96 +++---- .../data/data_prop_value_grid.ftl} | 176 ++++++------ .../data/data_select_prop_value.ftl} | 87 +++--- .../data/include/data_page_obj.ftl} | 11 +- .../include/data_page_obj_edit_grid_html.ftl | 26 ++ .../include/data_page_obj_edit_grid_js.ftl} | 71 +++-- .../data/include/data_page_obj_form.ftl} | 40 ++- .../data/include/data_page_obj_grid.ftl} | 15 +- .../data_page_obj_searchform_html.ftl} | 22 +- .../include/data_page_obj_searchform_js.ftl} | 18 +- .../driverEntity/driverEntity_form.ftl} | 95 +++---- .../driverEntity/driverEntity_grid.ftl} | 88 +++--- .../driverEntity/driverEntity_import.ftl} | 41 ++- .../src/main/webapp/WEB-INF/view/error.ftl | 47 ++++ .../webapp/WEB-INF/view/global_setting.ftl | 178 +++++++++++++ .../WEB-INF/view/include/html_doctype.ftl | 1 + .../webapp/WEB-INF/view/include/html_head.ftl | 38 +++ .../webapp/WEB-INF/view/include/html_logo.ftl | 3 + .../view/include/html_title_app_name.ftl | 1 + .../WEB-INF/view/include/import_global.ftl | 1 + .../include/page_js_obj.ftl} | 15 +- .../WEB-INF/view/include/page_obj_form.ftl | 16 ++ .../include/page_obj_grid.ftl} | 20 +- .../include/page_obj_pagination.ftl} | 18 +- .../include/page_obj_searchform.html.ftl} | 12 +- .../include/page_obj_searchform_js.ftl} | 14 +- .../src/main/webapp/WEB-INF/view/login.ftl | 102 +++++++ .../WEB-INF/{jsp/main.jsp => view/main.ftl} | 160 ++++++----- .../{jsp/register.jsp => view/register.ftl} | 57 ++-- .../webapp/WEB-INF/view/register_success.ftl | 25 ++ .../webapp/WEB-INF/view/reset_password.ftl | 220 +++++++++++++++ .../view/reset_password_request_history.ftl | 77 ++++++ .../schema/schema_build_url.ftl} | 57 ++-- .../schema/schema_form.ftl} | 122 ++++----- .../WEB-INF/view/schema_url_builder.ftl | 94 +++++++ .../webapp/WEB-INF/view/user/user_form.ftl | 164 ++++++++++++ .../webapp/WEB-INF/view/user/user_grid.ftl | 188 +++++++++++++ datagear-web/src/main/webapp/WEB-INF/web.xml | 3 +- datagear-web/src/main/webapp/index.html | 9 + datagear-web/src/main/webapp/index.jsp | 9 - .../webapp/static/script/datagear-model.js | 44 +++ 94 files changed, 2746 insertions(+), 2757 deletions(-) create mode 100644 datagear-web/src/main/java/org/datagear/web/freemarker/CustomFreeMarkerView.java create mode 100644 datagear-web/src/main/java/org/datagear/web/freemarker/WriteJsonTemplateDirectiveModel.java delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/about.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/change_theme_data.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/changelog.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/data/data_grid.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_jsp_define.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_page_obj_edit_grid_html.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/error.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/global_setting.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/html_doctype.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/html_head.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/html_logo.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/html_title_app_name.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_ajax_request.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_import.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_jstl.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_get_string_value.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_write_json.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_page_id.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_spring_context.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_form.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/login.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/register_success.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/reset_password.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/reset_password_request_history.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/schema_url_builder.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/user/user_form.jsp delete mode 100644 datagear-web/src/main/webapp/WEB-INF/jsp/user/user_grid.jsp create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/about.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/change_theme_data.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/changelog.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/data_form.jsp => view/data/data_form.ftl} (58%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/data/data_grid.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/data_prop_value_form.jsp => view/data/data_prop_value_form.ftl} (61%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/data_prop_value_grid.jsp => view/data/data_prop_value_grid.ftl} (66%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/data_select_prop_value.jsp => view/data/data_select_prop_value.ftl} (54%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj.jsp => view/data/include/data_page_obj.ftl} (84%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/data/include/data_page_obj_edit_grid_html.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj_edit_grid_js.jsp => view/data/include/data_page_obj_edit_grid_js.ftl} (92%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj_form.jsp => view/data/include/data_page_obj_form.ftl} (80%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj_grid.jsp => view/data/include/data_page_obj_grid.ftl} (77%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj_searchform_html.jsp => view/data/include/data_page_obj_searchform_html.ftl} (60%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/data/include/data_page_obj_searchform_js.jsp => view/data/include/data_page_obj_searchform_js.ftl} (91%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/driverEntity/driverEntity_form.jsp => view/driverEntity/driverEntity_form.ftl} (56%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/driverEntity/driverEntity_grid.jsp => view/driverEntity/driverEntity_grid.ftl} (52%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/driverEntity/driverEntity_import.jsp => view/driverEntity/driverEntity_import.ftl} (66%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/error.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/global_setting.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/html_doctype.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/html_head.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/html_logo.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/html_title_app_name.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/import_global.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/include/page_js_obj.jsp => view/include/page_js_obj.ftl} (79%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/include/page_obj_form.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/include/page_obj_grid.jsp => view/include/page_obj_grid.ftl} (91%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/include/page_obj_pagination.jsp => view/include/page_obj_pagination.ftl} (68%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/include/page_obj_searchform.html.jsp => view/include/page_obj_searchform.html.ftl} (54%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/include/page_obj_searchform_js.jsp => view/include/page_obj_searchform_js.ftl} (71%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/login.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/main.jsp => view/main.ftl} (80%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/register.jsp => view/register.ftl} (56%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/register_success.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/reset_password.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/reset_password_request_history.ftl rename datagear-web/src/main/webapp/WEB-INF/{jsp/schema/schema_build_url.jsp => view/schema/schema_build_url.ftl} (67%) rename datagear-web/src/main/webapp/WEB-INF/{jsp/schema/schema_form.jsp => view/schema/schema_form.ftl} (52%) create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/schema_url_builder.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/user/user_form.ftl create mode 100644 datagear-web/src/main/webapp/WEB-INF/view/user/user_grid.ftl create mode 100644 datagear-web/src/main/webapp/index.html delete mode 100644 datagear-web/src/main/webapp/index.jsp diff --git a/datagear-management/src/main/java/org/datagear/management/service/impl/SchemaServiceImpl.java b/datagear-management/src/main/java/org/datagear/management/service/impl/SchemaServiceImpl.java index 8ebb4cd3..3f00e2bc 100644 --- a/datagear-management/src/main/java/org/datagear/management/service/impl/SchemaServiceImpl.java +++ b/datagear-management/src/main/java/org/datagear/management/service/impl/SchemaServiceImpl.java @@ -113,7 +113,7 @@ public class SchemaServiceImpl extends AbstractMybatisEntityServiceguava 19.0 + + org.freemarker + freemarker + 2.3.28 + diff --git a/datagear-web/src/main/java/org/datagear/web/controller/AbstractController.java b/datagear-web/src/main/java/org/datagear/web/controller/AbstractController.java index c639cd39..fc2474f1 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/AbstractController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/AbstractController.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.datagear.persistence.Order; import org.datagear.persistence.Paging; @@ -461,6 +462,48 @@ public abstract class AbstractController } } + /** + * 获取HTTP错误时的{@linkplain OperationMessage}。 + * + * @param request + * @param response + * @return + */ + protected OperationMessage getOperationMessageForHttpError(HttpServletRequest request, HttpServletResponse response) + { + OperationMessage operationMessage = WebUtils.getOperationMessage(request); + + if (operationMessage == null) + { + Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); + + if (statusCode == null) + statusCode = response.getStatus(); + + String message = (String) request.getAttribute("javax.servlet.error.message"); + + String statusCodeKey = "error.httpError"; + + if (statusCode != null) + { + int sc = statusCode.intValue(); + statusCodeKey += "." + sc; + } + + try + { + message = getMessage(request, statusCodeKey, new Object[0]); + } + catch (Throwable t) + { + } + + operationMessage = OperationMessage.valueOfFail(statusCodeKey, message); + } + + return operationMessage; + } + /** * 字符串是否为空。 * diff --git a/datagear-web/src/main/java/org/datagear/web/controller/ControllerAdvice.java b/datagear-web/src/main/java/org/datagear/web/controller/ControllerAdvice.java index 29fdb0d1..8add11ba 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/ControllerAdvice.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/ControllerAdvice.java @@ -24,7 +24,11 @@ import org.datagear.persistence.PersistenceException; import org.datagear.persistence.UnsupportedDialectException; import org.datagear.persistence.support.SqlExpressionErrorException; import org.datagear.persistence.support.VariableExpressionErrorException; +import org.datagear.web.OperationMessage; import org.datagear.web.convert.IllegalSourceValueException; +import org.datagear.web.freemarker.WriteJsonTemplateDirectiveModel; +import org.datagear.web.util.DeliverContentTypeExceptionHandlerExceptionResolver; +import org.datagear.web.util.WebUtils; import org.springframework.http.HttpStatus; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; @@ -54,7 +58,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(MissingServletRequestParameterException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(BindException.class) @@ -64,7 +68,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(BindException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(MethodArgumentNotValidException.class) @@ -75,7 +79,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(MethodArgumentNotValidException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(AuthenticationFailedException.class) @@ -86,7 +90,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(AuthenticationFailedException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(IllegalInputException.class) @@ -96,7 +100,17 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(IllegalInputException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); + } + + @ExceptionHandler(IllegalArgumentException.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public String handleControllerIllegalArgumentException(HttpServletRequest request, HttpServletResponse response, + IllegalArgumentException exception) + { + setOperationMessageForThrowable(request, buildMessageCode(IllegalArgumentException.class), exception, false); + + return getErrorView(request, response); } @ExceptionHandler(RecordNotFoundException.class) @@ -106,7 +120,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(RecordNotFoundException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(RecordNotFoundOrPermissionDeniedException.class) @@ -117,7 +131,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(RecordNotFoundOrPermissionDeniedException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(SchemaNotFoundException.class) @@ -127,7 +141,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(SchemaNotFoundException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(IllegalSourceValueException.class) @@ -138,7 +152,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(IllegalSourceValueException.class), exception, false, exception.getSourceValue(), exception.getTargetType().getName()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(FileNotFoundException.class) @@ -149,7 +163,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(FileNotFoundException.class), exception, false, exception.getFileName()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DuplicateRecordException.class) @@ -160,7 +174,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(DuplicateRecordException.class), exception, false, exception.getExpectedCount(), exception.getActualCount()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(VariableExpressionErrorException.class) @@ -171,7 +185,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(VariableExpressionErrorException.class), exception.getCause(), false, exception.getExpression().getContent()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(SqlExpressionErrorException.class) @@ -182,7 +196,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(SqlExpressionErrorException.class), exception.getCause(), true, exception.getExpression().getContent()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(UnsupportedDialectException.class) @@ -192,7 +206,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(UnsupportedDialectException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(PersistenceException.class) @@ -206,7 +220,7 @@ public class ControllerAdvice extends AbstractController else setOperationMessageForThrowable(request, buildMessageCode(PersistenceException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DatabaseInfoResolverException.class) @@ -217,7 +231,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(DatabaseInfoResolverException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DatabaseModelResolverException.class) @@ -228,7 +242,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(DatabaseModelResolverException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(TableNotExistsException.class) @@ -239,7 +253,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(TableNotExistsException.class), exception, false, exception.getTableName()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(ConnectionSourceException.class) @@ -249,7 +263,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(ConnectionSourceException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DriverEntityManagerException.class) @@ -259,7 +273,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(DriverEntityManagerException.class), exception, true); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DriverNotFoundException.class) @@ -270,7 +284,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(DriverNotFoundException.class), exception, false, exception.getDriverClassName()); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(DriverClassFormatErrorException.class) @@ -281,7 +295,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(DriverClassFormatErrorException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(URLNotAcceptedException.class) @@ -291,7 +305,7 @@ public class ControllerAdvice extends AbstractController { setOperationMessageForThrowable(request, buildMessageCode(URLNotAcceptedException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(UnsupportedGetConnectionException.class) @@ -302,7 +316,7 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(UnsupportedGetConnectionException.class), exception, false); - return ERROR_PAGE_URL; + return getErrorView(request, response); } @ExceptionHandler(EstablishConnectionException.class) @@ -313,9 +327,49 @@ public class ControllerAdvice extends AbstractController setOperationMessageForThrowable(request, buildMessageCode(EstablishConnectionException.class), exception.getCause(), true); + return getErrorView(request, response); + } + + /** + * 获取错误信息视图。 + * + * @param request + * @param response + * @return + */ + protected String getErrorView(HttpServletRequest request, HttpServletResponse response) + { + setAttributeIfIsJsonResponse(request, response); return ERROR_PAGE_URL; } + /** + * 设置JSON响应的错误页面属性。 + * + * @param request + * @param response + */ + protected void setAttributeIfIsJsonResponse(HttpServletRequest request, HttpServletResponse response) + { + String expectedContentType = DeliverContentTypeExceptionHandlerExceptionResolver.getHandlerContentType(request); + if (expectedContentType != null && !expectedContentType.isEmpty()) + response.setContentType(expectedContentType); + + boolean isJsonResponse = WebUtils.isJsonResponse(response); + + request.setAttribute("isJsonResponse", isJsonResponse); + + if (isJsonResponse) + { + OperationMessage operationMessage = getOperationMessageForHttpError(request, response); + + request.setAttribute(WebUtils.KEY_OPERATION_MESSAGE, + WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(operationMessage)); + + response.setContentType(CONTENT_TYPE_JSON); + } + } + protected String buildMessageCode(Class clazz) { return buildMessageCode(clazz.getSimpleName()); diff --git a/datagear-web/src/main/java/org/datagear/web/controller/DataController.java b/datagear-web/src/main/java/org/datagear/web/controller/DataController.java index d5d6fc59..896b671d 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/DataController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/DataController.java @@ -13,6 +13,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; import java.sql.Connection; +import java.sql.Types; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -53,6 +54,7 @@ import org.datagear.web.format.DateFormatter; import org.datagear.web.format.SqlDateFormatter; import org.datagear.web.format.SqlTimeFormatter; import org.datagear.web.format.SqlTimestampFormatter; +import org.datagear.web.freemarker.WriteJsonTemplateDirectiveModel; import org.datagear.web.util.FileUtils; import org.datagear.web.util.ModelUtils; import org.datagear.web.util.WebUtils; @@ -88,6 +90,12 @@ public class DataController extends AbstractSchemaModelController public static final String KEY_IS_CLIENT_PAGE_DATA = "isClientPageData"; + public static final String KEY_TITLE_DISPLAY_NAME = "titleDisplayName"; + + public static final String KEY_TITLE_DISPLAY_DESC = "titleDisplayDesc"; + + public static final String KEY_CONDITION_SOURCE = "conditionSource"; + @Autowired private PersistenceManager persistenceManager; @@ -259,7 +267,12 @@ public class DataController extends AbstractSchemaModelController QueryResultMetaInfo queryResultMetaInfo = persistenceManager.getQueryResultMetaInfo(cn, model); - springModel.addAttribute("conditionSource", getPropertyPathDisplayNames(request, queryResultMetaInfo)); + springModel.addAttribute(KEY_CONDITION_SOURCE, WriteJsonTemplateDirectiveModel + .toWriteJsonTemplateModel(getPropertyPathDisplayNames(request, queryResultMetaInfo))); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, WebUtils.getLocale(request))); + springModel.addAttribute(KEY_TITLE_DISPLAY_DESC, + ModelUtils.displayDesc(model, WebUtils.getLocale(request))); } }.execute(); @@ -310,7 +323,9 @@ public class DataController extends AbstractSchemaModelController org.springframework.ui.Model springModel, Schema schema, Model model) throws Throwable { springModel.addAttribute("titleOperationMessageKey", "add"); - springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, "true"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, WebUtils.getLocale(request))); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, true); springModel.addAttribute("submitAction", "saveAdd"); } }.execute(); @@ -439,8 +454,10 @@ public class DataController extends AbstractSchemaModelController data = resultList.get(0); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("titleOperationMessageKey", "edit"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, WebUtils.getLocale(request))); springModel.addAttribute("submitAction", "saveEdit"); } }.execute(); @@ -556,9 +573,11 @@ public class DataController extends AbstractSchemaModelController data = resultList.get(0); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("titleOperationMessageKey", "view"); - springModel.addAttribute("readonly", "true"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, WebUtils.getLocale(request))); + springModel.addAttribute("readonly", true); } }.execute(); @@ -695,9 +714,18 @@ public class DataController extends AbstractSchemaModelController QueryResultMetaInfo queryResultMetaInfo = persistenceManager .getQueryPropValueSourceQueryResultMetaInfo(cn, model, data, propertyPathInfo); - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); - springModel.addAttribute("conditionSource", getPropertyPathDisplayNames(request, queryResultMetaInfo)); + springModel.addAttribute(KEY_CONDITION_SOURCE, WriteJsonTemplateDirectiveModel + .toWriteJsonTemplateModel(getPropertyPathDisplayNames(request, queryResultMetaInfo))); + + boolean isMultipleSelect = false; + if (request.getParameter("multiple") != null) + isMultipleSelect = true; + else + isMultipleSelect = MU.isMultipleProperty(propertyPathInfo.getPropertyTail()); + + springModel.addAttribute("isMultipleSelect", isMultipleSelect); } }.execute(); @@ -838,6 +866,8 @@ public class DataController extends AbstractSchemaModelController { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); + new VoidExecutor(request, response, springModel, schemaId, tableName, true) { @Override @@ -846,10 +876,12 @@ public class DataController extends AbstractSchemaModelController { Object data = modelDataConverter.convert(dataParam, model); - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); springModel.addAttribute("titleOperationMessageKey", "add"); - springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, "true"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, true); springModel.addAttribute("submitAction", "saveSinglePropValue"); } }.execute(); @@ -867,6 +899,7 @@ public class DataController extends AbstractSchemaModelController { final Object dataParam = getParamMap(request, "data"); final Object propertyValueParam = getParamMap(request, "propertyValue"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -881,13 +914,14 @@ public class DataController extends AbstractSchemaModelController if (propertyValueParam != null) { - propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, data); + propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); // 这里不应该使用convertToPropertyValue,因为它会添加双向关联,导致页面引用混乱,再保存时又会导致转换混乱 Object propertyValue = modelDataConverter.convert(propertyValueParam, propertyPathInfo.getModelTail()); - springModel.addAttribute("propertyValue", propertyValue); + springModel.addAttribute("propertyValue", + WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(propertyValue)); } if (isLoadPageData) @@ -906,13 +940,14 @@ public class DataController extends AbstractSchemaModelController // 设置最新原始属性值,因为受SelectOptions的影响,select到页面的data对象超过级联的属性值不会加载 propertyPathInfo.setValueTail(originalPropertyValue); - springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, - (originalPropertyValue == null ? "true" : "false")); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, (originalPropertyValue == null ? true : false)); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); springModel.addAttribute("titleOperationMessageKey", "edit"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); springModel.addAttribute("submitAction", "saveSinglePropValue"); } }.execute(); @@ -976,6 +1011,7 @@ public class DataController extends AbstractSchemaModelController { final Object dataParam = getParamMap(request, "data"); final Object propertyValueParam = getParamMap(request, "propertyValue"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -992,7 +1028,7 @@ public class DataController extends AbstractSchemaModelController if (isLoadPageData) { if (propertyPathInfo == null) - propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, data); + propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); LOBConversionContext.set(buildGetLobConversionSetting()); @@ -1009,7 +1045,7 @@ public class DataController extends AbstractSchemaModelController propertyValue = originalPropertyValue; if (originalPropertyValue == null) - springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, "true"); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, true); } else if (propertyValueParam != null) { @@ -1019,11 +1055,14 @@ public class DataController extends AbstractSchemaModelController propertyValue = modelDataConverter.convert(propertyValueParam, propertyPathInfo.getModelTail()); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); - springModel.addAttribute("propertyValue", propertyValue); - springModel.addAttribute("readonly", "true"); + springModel.addAttribute("propertyValue", + WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(propertyValue)); + springModel.addAttribute("readonly", true); springModel.addAttribute("titleOperationMessageKey", "view"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); } }.execute(); @@ -1039,6 +1078,7 @@ public class DataController extends AbstractSchemaModelController throws Throwable { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = PropertyPath.valueOf(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -1051,20 +1091,24 @@ public class DataController extends AbstractSchemaModelController Object data = modelDataConverter.convert(dataParam, model); + PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); + if (isLoadPageData) { - PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, - data); QueryResultMetaInfo queryResultMetaInfo = persistenceManager .getQueryMultiplePropValueQueryResultMetaInfo(cn, model, data, propertyPathInfo, true); - springModel.addAttribute("conditionSource", - getPropertyPathDisplayNames(request, queryResultMetaInfo)); + springModel.addAttribute(KEY_CONDITION_SOURCE, WriteJsonTemplateDirectiveModel + .toWriteJsonTemplateModel(getPropertyPathDisplayNames(request, queryResultMetaInfo))); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); springModel.addAttribute("titleOperationMessageKey", "edit"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); + springModel.addAttribute("isPrivatePropertyModel", + ModelUtils.isPrivatePropertyModelTail(propertyPathInfo)); } }.execute(); @@ -1118,6 +1162,7 @@ public class DataController extends AbstractSchemaModelController throws Throwable { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = PropertyPath.valueOf(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -1130,21 +1175,25 @@ public class DataController extends AbstractSchemaModelController Object data = modelDataConverter.convert(dataParam, model); + PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); + if (isLoadPageData) { - PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, - data); QueryResultMetaInfo queryResultMetaInfo = persistenceManager .getQueryMultiplePropValueQueryResultMetaInfo(cn, model, data, propertyPathInfo, true); - springModel.addAttribute("conditionSource", - getPropertyPathDisplayNames(request, queryResultMetaInfo)); + springModel.addAttribute(KEY_CONDITION_SOURCE, WriteJsonTemplateDirectiveModel + .toWriteJsonTemplateModel(getPropertyPathDisplayNames(request, queryResultMetaInfo))); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); - springModel.addAttribute("readonly", "true"); + springModel.addAttribute("readonly", true); springModel.addAttribute("titleOperationMessageKey", "view"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); + springModel.addAttribute("isPrivatePropertyModel", + ModelUtils.isPrivatePropertyModelTail(propertyPathInfo)); } }.execute(); @@ -1160,6 +1209,7 @@ public class DataController extends AbstractSchemaModelController throws Throwable { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); new VoidExecutor(request, response, springModel, schemaId, tableName, true) { @@ -1169,10 +1219,12 @@ public class DataController extends AbstractSchemaModelController { Object data = modelDataConverter.convert(dataParam, model); - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); springModel.addAttribute("titleOperationMessageKey", "add"); - springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, "true"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, true); springModel.addAttribute("submitAction", "saveAddMultiplePropValueElement"); } }.execute(); @@ -1310,6 +1362,7 @@ public class DataController extends AbstractSchemaModelController throws Throwable { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -1324,7 +1377,7 @@ public class DataController extends AbstractSchemaModelController if (isLoadPageData) { - PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, + PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); LOBConversionContext.set(buildGetLobConversionSetting()); @@ -1342,9 +1395,11 @@ public class DataController extends AbstractSchemaModelController propertyPathInfo.setValueTail(originalPropertyValueElement); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); springModel.addAttribute("titleOperationMessageKey", "edit"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); springModel.addAttribute("submitAction", "saveEditMultiplePropValueElement"); } }.execute(); @@ -1579,6 +1634,7 @@ public class DataController extends AbstractSchemaModelController throws Throwable { final Object dataParam = getParamMap(request, "data"); + final PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); final boolean isLoadPageData = isLoadPageDataRequest(request); new VoidExecutor(request, response, springModel, schemaId, tableName, true) @@ -1593,7 +1649,7 @@ public class DataController extends AbstractSchemaModelController if (isLoadPageData) { - PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPath, + PropertyPathInfo propertyPathInfo = ModelUtils.toPropertyPathInfoConcrete(model, propertyPathObj, data); LOBConversionContext.set(buildGetLobConversionSetting()); @@ -1607,10 +1663,12 @@ public class DataController extends AbstractSchemaModelController propertyPathInfo.setValueTail(resultList.get(0)); } - springModel.addAttribute("data", data); + springModel.addAttribute("data", WriteJsonTemplateDirectiveModel.toWriteJsonTemplateModel(data)); springModel.addAttribute("propertyPath", propertyPath); - springModel.addAttribute("readonly", "true"); + springModel.addAttribute("readonly", true); springModel.addAttribute("titleOperationMessageKey", "view"); + springModel.addAttribute(KEY_TITLE_DISPLAY_NAME, + ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request))); } }.execute(); @@ -1922,9 +1980,7 @@ public class DataController extends AbstractSchemaModelController */ protected boolean isClientPageDataRequest(HttpServletRequest request) { - Boolean re = getBooleanParamValue(request, KEY_IS_CLIENT_PAGE_DATA); - - return Boolean.TRUE.equals(re); + return WebUtils.getBooleanValue(request, KEY_IS_CLIENT_PAGE_DATA, false); } /** @@ -1938,26 +1994,7 @@ public class DataController extends AbstractSchemaModelController if (isClientPageDataRequest(request)) return false; - Boolean re = getBooleanParamValue(request, PARAM_IS_LOAD_PAGE_DATA); - - return !Boolean.FALSE.equals(re); - } - - /** - * 获取布尔参数值,如果没有参数将返回{@code null}。 - * - * @param request - * @param paramName - * @return - */ - protected Boolean getBooleanParamValue(HttpServletRequest request, String paramName) - { - String value = request.getParameter(paramName); - - if (value == null) - return null; - - return ("true".equals(value) || "1".equals(value)); + return WebUtils.getBooleanValue(request, PARAM_IS_LOAD_PAGE_DATA, true); } /** @@ -1984,6 +2021,11 @@ public class DataController extends AbstractSchemaModelController // 编辑表格需要表单属性 setFormPageAttributes(request, springModel); + + springModel.addAttribute("Types_CLOB", Types.CLOB); + springModel.addAttribute("Types_NCLOB", Types.NCLOB); + springModel.addAttribute("Types_LONGNVARCHAR", Types.LONGNVARCHAR); + springModel.addAttribute("Types_LONGVARCHAR", Types.LONGVARCHAR); } /** @@ -2001,6 +2043,36 @@ public class DataController extends AbstractSchemaModelController springModel.addAttribute("sqlTimestampFormat", this.sqlTimestampFormatter.getParsePatternDesc(locale)); springModel.addAttribute("sqlTimeFormat", this.sqlTimeFormatter.getParsePatternDesc(locale)); springModel.addAttribute("filePropertyLabelValue", this.blobToFilePlaceholderName); + + if (!containsAttributes(request, springModel, KEY_IS_CLIENT_PAGE_DATA)) + { + boolean isClientPageData = WebUtils.getBooleanValue(request, KEY_IS_CLIENT_PAGE_DATA, false); + springModel.addAttribute(KEY_IS_CLIENT_PAGE_DATA, isClientPageData); + } + + if (!containsAttributes(request, springModel, "batchSet")) + { + boolean batchSet = WebUtils.getBooleanValue(request, "batchSet", false); + springModel.addAttribute("batchSet", batchSet); + } + + if (!containsAttributes(request, springModel, "ignorePropertyName")) + { + String ignorePropertyName = WebUtils.getStringValue(request, "ignorePropertyName", ""); + springModel.addAttribute("ignorePropertyName", ignorePropertyName); + } + } + + protected boolean containsAttributes(HttpServletRequest request, org.springframework.ui.Model springModel, + String name) + { + if (request.getAttribute(name) != null) + return true; + + if (springModel.containsAttribute(name)) + return true; + + return false; } /** diff --git a/datagear-web/src/main/java/org/datagear/web/controller/DriverEntityController.java b/datagear-web/src/main/java/org/datagear/web/controller/DriverEntityController.java index 2a90d0a9..6f1f2c4b 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/DriverEntityController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/DriverEntityController.java @@ -285,7 +285,7 @@ public class DriverEntityController extends AbstractController model.addAttribute("driverEntity", driverEntity); model.addAttribute(KEY_TITLE_MESSAGE_KEY, "driverEntity.viewDriverEntity"); - model.addAttribute(KEY_READONLY, "true"); + model.addAttribute(KEY_READONLY, true); return "/driverEntity/driverEntity_form"; } @@ -312,7 +312,7 @@ public class DriverEntityController extends AbstractController public String select(HttpServletRequest request, org.springframework.ui.Model model) { model.addAttribute(KEY_TITLE_MESSAGE_KEY, "driverEntity.selectDriverEntity"); - model.addAttribute(KEY_SELECTONLY, "true"); + model.addAttribute(KEY_SELECTONLY, true); return "/driverEntity/driverEntity_grid"; } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/ErrorController.java b/datagear-web/src/main/java/org/datagear/web/controller/ErrorController.java index f51c48e6..75e2ef05 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/ErrorController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/ErrorController.java @@ -5,7 +5,10 @@ package org.datagear.web.controller; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.datagear.web.OperationMessage; +import org.datagear.web.util.WebUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,9 +21,18 @@ import org.springframework.web.bind.annotation.RequestMapping; @Controller public class ErrorController extends AbstractController { - @RequestMapping("/error") - public String handleError(HttpServletRequest request) + public ErrorController() { + super(); + } + + @RequestMapping("/error") + public String handleError(HttpServletRequest request, HttpServletResponse response, + org.springframework.ui.Model springModel) + { + OperationMessage operationMessage = getOperationMessageForHttpError(request, response); + WebUtils.setOperationMessage(request, operationMessage); + return "/error"; } } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/GlobalSettingController.java b/datagear-web/src/main/java/org/datagear/web/controller/GlobalSettingController.java index 09646fe8..39ad4568 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/GlobalSettingController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/GlobalSettingController.java @@ -10,8 +10,8 @@ import javax.servlet.http.HttpServletResponse; import org.datagear.management.domain.GlobalSetting; import org.datagear.management.domain.SmtpSetting; -import org.datagear.management.domain.User; import org.datagear.management.domain.SmtpSetting.ConnectionType; +import org.datagear.management.domain.User; import org.datagear.management.service.GlobalSettingService; import org.datagear.web.OperationMessage; import org.datagear.web.convert.ClassDataConverter; @@ -79,6 +79,9 @@ public class GlobalSettingController extends AbstractController } model.addAttribute("globalSetting", globalSetting); + model.addAttribute("connectionTypePlain", ConnectionType.PLAIN); + model.addAttribute("connectionTypeSsl", ConnectionType.SSL); + model.addAttribute("connectionTypeTls", ConnectionType.TLS); return "/global_setting"; } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/LoginController.java b/datagear-web/src/main/java/org/datagear/web/controller/LoginController.java index 547734c7..49d3d2e1 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/LoginController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/LoginController.java @@ -11,6 +11,9 @@ import java.net.URLEncoder; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.WebAttributes; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -50,6 +53,28 @@ public class LoginController extends AbstractController @RequestMapping public String login(HttpServletRequest request) { + String loginUser = (String) request.getSession() + .getAttribute(org.datagear.web.controller.RegisterController.SESSION_KEY_REGISTER_USER_NAME); + + // 参考org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler.saveException() + AuthenticationException authenticationException = (AuthenticationException) request.getSession() + .getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + if (authenticationException != null) + { + request.getSession().removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); + + @SuppressWarnings("deprecation") + Authentication authentication = authenticationException.getAuthentication(); + + if (authentication != null && authentication.getPrincipal() != null) + loginUser = authentication.getPrincipal().toString(); + } + + if (loginUser == null) + loginUser = ""; + + request.setAttribute("loginUser", loginUser); + request.setAttribute("authenticationFailed", (authenticationException != null)); request.setAttribute("disableRegister", this.disableRegister); return "/login"; diff --git a/datagear-web/src/main/java/org/datagear/web/controller/MainController.java b/datagear-web/src/main/java/org/datagear/web/controller/MainController.java index fdd2fbfd..586c2b20 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/MainController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/MainController.java @@ -9,10 +9,12 @@ import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.datagear.management.util.Version; import org.datagear.management.util.VersionContent; import org.datagear.web.util.ChangelogResolver; +import org.datagear.web.util.WebUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -86,10 +88,25 @@ public class MainController extends AbstractController * @param model * @return */ - @RequestMapping("/main") - public String main(HttpServletRequest request, Model model) + @RequestMapping("/") + public String main(HttpServletRequest request, HttpServletResponse response, Model model) + { + return mainForIndexHtml(request, response, model); + } + + /** + * 打开主页面。 + * + * @param request + * @param response + * @param model + * @return + */ + @RequestMapping("/index.html") + public String mainForIndexHtml(HttpServletRequest request, HttpServletResponse response, Model model) { request.setAttribute("disableRegister", this.disableRegister); + request.setAttribute("currentUser", WebUtils.getUser(request, response)); return "/main"; } @@ -139,9 +156,11 @@ public class MainController extends AbstractController return "/changelog"; } - @RequestMapping(value = "/changeThemeData", produces = CONTENT_TYPE_JSON) - public String changeThemeData(HttpServletRequest request) + @RequestMapping(value = "/changeThemeData") + public String changeThemeData(HttpServletRequest request, HttpServletResponse response) { + response.setContentType(CONTENT_TYPE_JSON); + return "/change_theme_data"; } } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/ResetPasswordController.java b/datagear-web/src/main/java/org/datagear/web/controller/ResetPasswordController.java index a3664997..520686cf 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/ResetPasswordController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/ResetPasswordController.java @@ -130,6 +130,8 @@ public class ResetPasswordController extends AbstractController session.setAttribute(KEY_STEP, resetPasswordStep); } + request.setAttribute("step", resetPasswordStep); + return "/reset_password"; } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/SchemaController.java b/datagear-web/src/main/java/org/datagear/web/controller/SchemaController.java index 2e06f409..cfca2382 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/SchemaController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/SchemaController.java @@ -176,7 +176,7 @@ public class SchemaController extends AbstractSchemaModelController model.addAttribute("schema", schema); model.addAttribute(KEY_TITLE_MESSAGE_KEY, "schema.viewSchema"); - model.addAttribute(KEY_READONLY, "true"); + model.addAttribute(KEY_READONLY, true); return "/schema/schema_form"; } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/SchemaUrlBuilderController.java b/datagear-web/src/main/java/org/datagear/web/controller/SchemaUrlBuilderController.java index fef99b93..17f3e9dc 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/SchemaUrlBuilderController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/SchemaUrlBuilderController.java @@ -111,7 +111,7 @@ public class SchemaUrlBuilderController extends AbstractController implements Se @RequestParam(value = "scriptCode", required = false) String scriptCode) throws IOException { request.setAttribute("scriptCode", scriptCode); - request.setAttribute("preview", "1"); + request.setAttribute("preview", true); return "/schema/schema_build_url"; } diff --git a/datagear-web/src/main/java/org/datagear/web/controller/UserController.java b/datagear-web/src/main/java/org/datagear/web/controller/UserController.java index 25483f98..418791eb 100644 --- a/datagear-web/src/main/java/org/datagear/web/controller/UserController.java +++ b/datagear-web/src/main/java/org/datagear/web/controller/UserController.java @@ -168,7 +168,7 @@ public class UserController extends AbstractController model.addAttribute("user", user); model.addAttribute(KEY_TITLE_MESSAGE_KEY, "user.viewUser"); - model.addAttribute(KEY_READONLY, "true"); + model.addAttribute(KEY_READONLY, true); return "/user/user_form"; } diff --git a/datagear-web/src/main/java/org/datagear/web/freemarker/CustomFreeMarkerView.java b/datagear-web/src/main/java/org/datagear/web/freemarker/CustomFreeMarkerView.java new file mode 100644 index 00000000..31031bb8 --- /dev/null +++ b/datagear-web/src/main/java/org/datagear/web/freemarker/CustomFreeMarkerView.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018 datagear.org. All Rights Reserved. + */ + +package org.datagear.web.freemarker; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.datagear.web.util.WebUtils; +import org.springframework.web.servlet.view.freemarker.FreeMarkerView; + +/** + * 自定义{@linkplain FreeMarkerView},实现一些本系统需要的特性。 + * + * @author datagear@163.com + * + */ +public class CustomFreeMarkerView extends FreeMarkerView +{ + /** 变量:是否是ajax请求 */ + public static final String VAR_IS_AJAX_REQUEST = "isAjaxRequest"; + + /** 变量:应用根路径 */ + public static final String VAR_CONTEXT_PATH = "contextPath"; + + /** 变量:页面ID关键字 */ + public static final String VAR_PAGE_ID = WebUtils.KEY_PAGE_ID; + + /** 变量:父页面ID关键字 */ + public static final String VAR_PARENT_PAGE_ID = WebUtils.KEY_PARENT_PAGE_ID; + + public CustomFreeMarkerView() + { + super(); + } + + @Override + protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception + { + super.exposeHelpers(model, request); + + model.put(VAR_CONTEXT_PATH, request.getContextPath()); + model.put(VAR_IS_AJAX_REQUEST, WebUtils.isAjaxRequest(request)); + + model.put(VAR_PAGE_ID, WebUtils.generatePageId()); + model.put(VAR_PARENT_PAGE_ID, WebUtils.getParentPageId(request)); + } +} diff --git a/datagear-web/src/main/java/org/datagear/web/freemarker/WriteJsonTemplateDirectiveModel.java b/datagear-web/src/main/java/org/datagear/web/freemarker/WriteJsonTemplateDirectiveModel.java new file mode 100644 index 00000000..39aeaeb1 --- /dev/null +++ b/datagear-web/src/main/java/org/datagear/web/freemarker/WriteJsonTemplateDirectiveModel.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2018 datagear.org. All Rights Reserved. + */ + +package org.datagear.web.freemarker; + +import java.io.IOException; +import java.util.Collection; +import java.util.Map; + +import com.alibaba.fastjson.serializer.JSONSerializer; +import com.alibaba.fastjson.serializer.SerializeConfig; +import com.alibaba.fastjson.serializer.SerializeWriter; +import com.alibaba.fastjson.serializer.SerializerFeature; + +import freemarker.core.Environment; +import freemarker.ext.util.WrapperTemplateModel; +import freemarker.template.TemplateDirectiveBody; +import freemarker.template.TemplateDirectiveModel; +import freemarker.template.TemplateException; +import freemarker.template.TemplateModel; +import freemarker.template.TemplateModelException; +import freemarker.template.utility.DeepUnwrap; + +/** + * 将参数输出为JSON的{@linkplain WriteJsonTemplateDirectiveModel}。 + * + * @author datagear@163.com + * + */ +public class WriteJsonTemplateDirectiveModel implements TemplateDirectiveModel +{ + private SerializeConfig serializeConfig; + private SerializerFeature[] serializerFeatures; + + public WriteJsonTemplateDirectiveModel() + { + super(); + } + + public WriteJsonTemplateDirectiveModel(SerializeConfig serializeConfig, SerializerFeature[] serializerFeatures) + { + super(); + this.serializeConfig = serializeConfig; + this.serializerFeatures = serializerFeatures; + } + + public SerializeConfig getSerializeConfig() + { + return serializeConfig; + } + + public void setSerializeConfig(SerializeConfig serializeConfig) + { + this.serializeConfig = serializeConfig; + } + + public SerializerFeature[] getSerializerFeatures() + { + return serializerFeatures; + } + + public void setSerializerFeatures(SerializerFeature[] serializerFeatures) + { + this.serializerFeatures = serializerFeatures; + } + + @SuppressWarnings("rawtypes") + @Override + public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) + throws TemplateException, IOException + { + if (params.size() != 1) + throw new TemplateModelException("The directive only allow one parameter."); + + SerializeWriter serializeWriter = new SerializeWriter(env.getOut(), this.serializerFeatures); + JSONSerializer serializer = new JSONSerializer(serializeWriter, this.serializeConfig); + + @SuppressWarnings("unchecked") + Collection args = ((Map) params).values(); + + for (TemplateModel arg : args) + { + Object obj = unwrap(arg); + + try + { + serializer.write(obj); + } + catch (Throwable t) + { + if (t instanceof IOException) + throw (IOException) t; + else + throw new TemplateException(t, env); + } + finally + { + serializer.close(); + } + } + } + + /** + * 获取{@linkplain TemplateModel}的原始对象。 + *

+ * 由于freemarker的{@linkplain DeepUnwrap}处理存在循环引用的对象时会出现死循环,因而不能采用, + * 这里折中一下,要求此指令的参数对象必须是{@linkplain WrapperTemplateModel}。 + *

+ * + * @param model + * @return + * @throws TemplateModelException + */ + protected Object unwrap(TemplateModel model) throws TemplateModelException + { + if (model == null) + return null; + + if (model instanceof WrapperTemplateModel) + { + return ((WrapperTemplateModel) model).getWrappedObject(); + } + + throw new TemplateModelException("Cannot unwrap model of type " + model.getClass().getName()); + } + + /** + * 将对象包装为{@linkplain WrapperTemplateModel},这样就可以使用此类对应的指令,并且能够处理循环引用对象。 + * + * @param obj + * @return + */ + public static TemplateModel toWriteJsonTemplateModel(Object obj) + { + if (obj == null) + return null; + + return new SimpleWrapperTemplateModel(obj); + } + + protected static class SimpleWrapperTemplateModel implements WrapperTemplateModel + { + private Object object; + + public SimpleWrapperTemplateModel() + { + super(); + } + + public SimpleWrapperTemplateModel(Object object) + { + super(); + this.object = object; + } + + public Object getObject() + { + return object; + } + + public void setObject(Object object) + { + this.object = object; + } + + @Override + public Object getWrappedObject() + { + return object; + } + } +} diff --git a/datagear-web/src/main/java/org/datagear/web/util/WebUtils.java b/datagear-web/src/main/java/org/datagear/web/util/WebUtils.java index f9f12949..d9a859b3 100644 --- a/datagear-web/src/main/java/org/datagear/web/util/WebUtils.java +++ b/datagear-web/src/main/java/org/datagear/web/util/WebUtils.java @@ -281,6 +281,20 @@ public class WebUtils return (__contentType.indexOf("json") >= 0); } + /** + * 判断请求是否是ajax请求。 + * + * @param request + * @return + */ + public static boolean isAjaxRequest(HttpServletRequest request) + { + // 是否ajax请求,jquery库ajax可以使用此方案判断 + boolean ajaxRequest = (request.getHeader("x-requested-with") != null); + + return ajaxRequest; + } + /** * 获取页面ID。 *

@@ -415,4 +429,60 @@ public class WebUtils String pageId = getPageId(request); return pageId + "-" + elementId; } + + /** + * 从请求获取布尔值。 + * + * @param request + * @param name + * @param defaultValue + * @return + */ + public static boolean getBooleanValue(HttpServletRequest request, String name, boolean defaultValue) + { + Object value = request.getAttribute(name); + + if (value != null) + { + if (value instanceof Boolean) + return (Boolean) value; + + return ("true".equals(value.toString()) || "1".equals(value.toString())); + } + + String paramValue = request.getParameter(name); + + if (paramValue != null) + return ("true".equals(paramValue) || "1".equals(paramValue)); + + return defaultValue; + } + + /** + * 从请求获取字符串值。 + * + * @param request + * @param name + * @param defaultValue + * @return + */ + public static String getStringValue(HttpServletRequest request, String name, String defaultValue) + { + Object value = request.getAttribute(name); + + if (value != null) + { + if (value instanceof String) + return (String) value; + + return value.toString(); + } + + String paramValue = request.getParameter(name); + + if (paramValue != null) + return paramValue; + + return defaultValue; + } } diff --git a/datagear-web/src/main/resources/datagear-servlet.xml b/datagear-web/src/main/resources/datagear-servlet.xml index b4f0724a..d9fb9228 100644 --- a/datagear-web/src/main/resources/datagear-servlet.xml +++ b/datagear-web/src/main/resources/datagear-servlet.xml @@ -45,10 +45,44 @@ + + + + + + + + + + + + + yyyy-MM-dd HH:mm:ss + yyyy-MM-dd + #.## + + + + + + + + + + + + + + + + + + diff --git a/datagear-web/src/main/resources/locales/datagear.properties b/datagear-web/src/main/resources/locales/datagear.properties index e9968fea..492f94b3 100644 --- a/datagear-web/src/main/resources/locales/datagear.properties +++ b/datagear-web/src/main/resources/locales/datagear.properties @@ -83,6 +83,7 @@ error.MethodArgumentNotValidException=\u8F93\u5165\u975E\u6CD5 error.MissingServletRequestParameterException=\u8F93\u5165\u975E\u6CD5 error.BindException=\u8F93\u5165\u975E\u6CD5 error.IllegalInputException=\u8F93\u5165\u975E\u6CD5 +error.IllegalArgumentException=\u8F93\u5165\u975E\u6CD5 error.RecordNotFoundException=\u8BB0\u5F55\u672A\u627E\u5230\uFF0C\u6216\u8BB8\u5DF2\u88AB\u5220\u9664 error.RecordNotFoundOrPermissionDeniedException=\u8BB0\u5F55\u6216\u8BB8\u5DF2\u88AB\u5220\u9664\uFF0C\u6216\u8005\u60A8\u6CA1\u6709\u64CD\u4F5C\u6743\u9650 error.SchemaNotFoundException=\u672A\u627E\u5230\u6B64\u6570\u636E\u5E93 @@ -129,6 +130,7 @@ driverEntity.editDriverEntity=\u7F16\u8F91\u6570\u636E\u5E93\u9A71\u52A8\u7A0B\u driverEntity.viewDriverEntity=\u67E5\u770B\u6570\u636E\u5E93\u9A71\u52A8\u7A0B\u5E8F driverEntity.manageDriverEntity=\u7BA1\u7406\u6570\u636E\u5E93\u9A71\u52A8\u7A0B\u5E8F driverEntity.selectDriverEntity=\u9009\u62E9\u6570\u636E\u5E93\u9A71\u52A8\u7A0B\u5E8F +driverEntity.id=ID driverEntity.driverClassName=\u9A71\u52A8\u7A0B\u5E8F\u7C7B\u540D driverEntity.displayName=\u9A71\u52A8\u7A0B\u5E8F\u6807\u9898 driverEntity.displayDesc=\u9A71\u52A8\u7A0B\u5E8F\u63CF\u8FF0 @@ -298,6 +300,7 @@ user.viewUser=\u67E5\u770B\u7528\u6237 user.manageUser=\u7BA1\u7406\u7528\u6237 user.selectUser=\u9009\u62E9\u7528\u6237 user.personalSet=\u4E2A\u4EBA\u8BBE\u7F6E +user.user.id=ID user.name=\u7528\u6237\u540D user.password=\u5BC6\u7801 user.realName=\u59D3\u540D diff --git a/datagear-web/src/main/webapp/WEB-INF/changelog.txt b/datagear-web/src/main/webapp/WEB-INF/changelog.txt index 742b0f73..a5ab6124 100644 --- a/datagear-web/src/main/webapp/WEB-INF/changelog.txt +++ b/datagear-web/src/main/webapp/WEB-INF/changelog.txt @@ -34,3 +34,4 @@ --v1.1.1 ----------------------------------------- +修复:修复集成软件包在JRE8及以上版本无法正常运行的BUG; \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/about.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/about.jsp deleted file mode 100644 index 59f07e7b..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/about.jsp +++ /dev/null @@ -1,57 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='about.about' /> - - -

-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
- -
-
-
-
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/change_theme_data.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/change_theme_data.jsp deleted file mode 100644 index 3ad4724d..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/change_theme_data.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_jstl.jsp" %> -[ - { - "selector" : "#css_jquery_ui", - "attr" : "href", - "value" : "<%=request.getContextPath()%>/static/theme//jquery-ui-1.12.1/jquery-ui.css" - }, - { - "selector" : "#css_jquery_ui_theme", - "attr" : "href", - "value" : "<%=request.getContextPath()%>/static/theme//jquery-ui-1.12.1/jquery-ui.theme.css" - }, - { - "selector" : "#css_common", - "attr" : "href", - "value" : "<%=request.getContextPath()%>/static/theme//common.css" - } -] \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/changelog.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/changelog.jsp deleted file mode 100644 index cd37c369..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/changelog.jsp +++ /dev/null @@ -1,73 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='changelog.changelog' /> - - -
- <%if(!ajaxRequest){%> -
- <%@ include file="include/html_logo.jsp" %> -
- <%}%> -
-
-
- -
-
- -
-
- -
-
-
-
- -
-
-
    - -
  • -
    -
-
-
-
-
-
- - - -
-
-
-
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_grid.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_grid.jsp deleted file mode 100644 index 6d28408a..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_grid.jsp +++ /dev/null @@ -1,167 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@page import="org.datagear.web.vo.PropertyPathDisplayName"%> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/jsp_method_write_json.jsp" %> -<%@ include file="include/data_jsp_define.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//是否只读操作,允许为null -boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, "readonly"))); -//可用的查询条件列表,不允许为null -List conditionSource = (List)request.getAttribute("conditionSource"); -%> - - -<%@ include file="../include/html_head.jsp" %> - - <%@ include file="../include/html_title_app_name.jsp" %> - <fmt:message key='query' /> - <fmt:message key='titleSeparator' /> - <%=WebUtils.escapeHtml(ModelUtils.displayName(model, WebUtils.getLocale(request)))%> - <% - String diplayDesc = ModelUtils.displayDesc(model, WebUtils.getLocale(request)); - if(diplayDesc != null && !diplayDesc.isEmpty()){ - %> - <fmt:message key='bracketLeft' /> - <%=WebUtils.escapeHtml(diplayDesc)%> - <fmt:message key='bracketRight' /> - <%}%> - <fmt:message key='bracketLeft' /> - <%=WebUtils.escapeHtml(schema.getTitle())%> - <fmt:message key='bracketRight' /> - - - -<%if(!ajaxRequest){%> -
-<%}%> -
-
- -
- <%if(readonly){%> - - <%}else{%> - - - - - <%}%> -
-
-
- -
-
-
- <%if(!readonly){%> - <%@ include file="include/data_page_obj_edit_grid_html.jsp" %> - <%}%> -
- -
-
-
-<%if(!ajaxRequest){%> -
-<%}%> -<%@ include file="include/data_page_obj.jsp" %> -<%@ include file="include/data_page_obj_searchform_js.jsp" %> -<%@ include file="../include/page_obj_pagination.jsp" %> -<%@ include file="include/data_page_obj_grid.jsp" %> -<%if(!readonly){%> -<%@ include file="include/data_page_obj_edit_grid_js.jsp" %> -<%}%> - - - diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_jsp_define.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_jsp_define.jsp deleted file mode 100644 index 10c6d4f0..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_jsp_define.jsp +++ /dev/null @@ -1,20 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<%@ page import="java.util.List"%> -<%@ page import="org.datagear.model.Model"%> -<%@ page import="org.datagear.model.Property"%> -<%@ page import="org.datagear.model.support.DynamicBean"%> -<%@ page import="org.datagear.model.support.MU"%> -<%@ page import="org.datagear.model.support.PropertyPath"%> -<%@ page import="org.datagear.model.support.PropertyPathInfo"%> -<%@ page import="org.datagear.management.domain.Schema"%> -<%@ page import="org.datagear.persistence.PagingData"%> -<%@ page import="org.datagear.web.util.ModelUtils" %> -<% -Schema schema = (Schema)request.getAttribute("schema"); -Model model = (Model)request.getAttribute("model"); -%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_page_obj_edit_grid_html.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_page_obj_edit_grid_html.jsp deleted file mode 100644 index 2f960ead..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/data/include/data_page_obj_edit_grid_html.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@page import="org.datagear.web.util.WebUtils"%> -<%-- -编辑表格功能HTML片段。 ---%> -
-
- - -
-
- - - -
-
-<% -String editGridFormPageId_html = WebUtils.generatePageId(); -request.setAttribute("editGridFormPageId", editGridFormPageId_html); -%> -
-
-
- -
-
-
-
-
-
-
\ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/error.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/error.jsp deleted file mode 100644 index f7daa9f4..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/error.jsp +++ /dev/null @@ -1,104 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%> -<%@ page import="org.springframework.web.context.WebApplicationContext"%> -<%@ page import="org.datagear.web.OperationMessage"%> -<%@ page import="org.datagear.web.util.DeliverContentTypeExceptionHandlerExceptionResolver"%> -<%@ page import="org.springframework.http.HttpStatus" %> -<%@ page import="java.io.Serializable"%> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_method_write_json.jsp" %> -<% -String expectedContentType = DeliverContentTypeExceptionHandlerExceptionResolver.getHandlerContentType(request); -if(expectedContentType != null && !expectedContentType.isEmpty()) - response.setContentType(expectedContentType); - -OperationMessage operationMessage = WebUtils.getOperationMessage(request); - -if(operationMessage == null) -{ - WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(application); - - Integer statusCode = (Integer)request.getAttribute("javax.servlet.error.status_code"); - - if(statusCode == null) - statusCode = response.getStatus(); - - String message = (String)request.getAttribute("javax.servlet.error.message"); - Throwable throwable = (Throwable)request.getAttribute("javax.servlet.error.exception"); - - String statusCodeKey = "error.httpError"; - - if(statusCode != null) - { - int sc = statusCode.intValue(); - statusCodeKey += "." + sc; - } - - try - { - message = webApplicationContext.getMessage(statusCodeKey, new Object[0], WebUtils.getLocale(request)); - } - catch(Throwable t){} - - operationMessage = OperationMessage.valueOfFail(statusCodeKey, message); - WebUtils.setOperationMessage(request, operationMessage); -} - -boolean jsonResponse = WebUtils.isJsonResponse(response); -if(jsonResponse) -{ - writeJson(application, out, operationMessage); -} -else -{ -%> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='error.errorOccure' /> - - -<%if(ajaxRequest){%> -
-
- <%=operationMessage.getMessage()%> -
- <%if(operationMessage.hasDetail()){%> -
-
<%=operationMessage.getDetail()%>
-
- <%}%> -
-<%}else{%> -
-
- <%@ include file="include/html_logo.jsp" %> -
- "> -
-
-
-
-
- <%=operationMessage.getMessage()%> -
- <%if(operationMessage.hasDetail()){%> -
-
<%=operationMessage.getDetail()%>
-
- <%}%> -
-
-
-<%}%> - - -<%}%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/global_setting.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/global_setting.jsp deleted file mode 100644 index b7d21d6e..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/global_setting.jsp +++ /dev/null @@ -1,189 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.management.domain.SmtpSetting.ConnectionType" %> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/jsp_method_get_string_value.jsp" %> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='globalSetting.smtpSetting' /> - - -
-
-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -    - -
-
-
-
- -    - -
-
-
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_doctype.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_doctype.jsp deleted file mode 100644 index ca87b0b3..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_doctype.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%-- -依赖: -jsp_ajax_request.jsp ---%> -<%@ page language="java" pageEncoding="UTF-8"%> -<%if(!ajaxRequest){%> - -<%}%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_head.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_head.jsp deleted file mode 100644 index 3c3e26da..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_head.jsp +++ /dev/null @@ -1,49 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%-- -依赖: -jsp_ajax_request.jsp -jsp_jstl.jsp ---%> -<%@ page language="java" pageEncoding="UTF-8"%> - - - -<%if(!ajaxRequest){%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<%}%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_logo.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_logo.jsp deleted file mode 100644 index 81bd0bb3..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_logo.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%-- -依赖: -jsp_jstl.jsp ---%> -<%@ page language="java" pageEncoding="UTF-8"%> - diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_title_app_name.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_title_app_name.jsp deleted file mode 100644 index 62b606cd..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/html_title_app_name.jsp +++ /dev/null @@ -1,12 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%-- -依赖: -jsp_ajax_request.jsp -jsp_jstl.jsp ---%> -<%@ page language="java" pageEncoding="UTF-8"%> -<%if(!ajaxRequest){%> - <%}%> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_ajax_request.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_ajax_request.jsp deleted file mode 100644 index 6d897c9a..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_ajax_request.jsp +++ /dev/null @@ -1,11 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<% -//是否ajax请求,jquery库ajax可以使用此方案判断 -boolean ajaxRequest=(request.getHeader("x-requested-with") != null); -request.setAttribute("ajaxRequest", ajaxRequest); -%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_import.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_import.jsp deleted file mode 100644 index db364e96..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_import.jsp +++ /dev/null @@ -1,7 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<%@ page import="org.datagear.web.util.WebUtils" %> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_jstl.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_jstl.jsp deleted file mode 100644 index 84b579c3..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_jstl.jsp +++ /dev/null @@ -1,11 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> -<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> - diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_get_string_value.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_get_string_value.jsp deleted file mode 100644 index d36bb560..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_get_string_value.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<%! -protected String getStringValue(HttpServletRequest request, String name) -{ - Object attrValue = request.getAttribute(name); - - if(attrValue != null && attrValue instanceof String) - return (String)attrValue; - - return request.getParameter(name); -} - -protected String getStringValue(HttpServletRequest request, String name, String defaultValue) -{ - String value = getStringValue(request, name); - - return (value == null ? "" : value); -} -%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_write_json.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_write_json.jsp deleted file mode 100644 index a6d1f492..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_method_write_json.jsp +++ /dev/null @@ -1,35 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<%@page import="com.alibaba.fastjson.serializer.SerializeConfig"%> -<%@page import="com.alibaba.fastjson.serializer.JSONSerializer"%> -<%@page import="com.alibaba.fastjson.serializer.SerializeWriter"%> -<%@ page import="com.alibaba.fastjson.serializer.SerializerFeature" %> -<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%> -<%@ page import="org.springframework.web.context.WebApplicationContext"%> -<%@ page import="java.io.Writer"%> -<%@ page import="java.io.IOException"%> -<%! -protected void writeJson(ServletContext servletContext, Writer out, Object object) throws IOException -{ - WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); - - SerializeConfig fastJsonConfig = (SerializeConfig)webApplicationContext.getBean("serializeConfig"); - SerializerFeature[] serializerFeatures = (SerializerFeature[])webApplicationContext.getBean("serializerFeatures"); - - SerializeWriter serializeWriter = new SerializeWriter(out, serializerFeatures); - JSONSerializer serializer = new JSONSerializer(serializeWriter, fastJsonConfig); - - try - { - serializer.write(object); - } - finally - { - serializer.close(); - } -} -%> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_page_id.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_page_id.jsp deleted file mode 100644 index 25187a9b..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_page_id.jsp +++ /dev/null @@ -1,11 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8" %> -<%@ page import="org.datagear.web.util.WebUtils" %> -<% -//设置页面客户端对象定义ID -WebUtils.setPageId(request); -%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_spring_context.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_spring_context.jsp deleted file mode 100644 index e1b5cbbb..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/jsp_spring_context.jsp +++ /dev/null @@ -1,11 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%> -<%@ page import="org.springframework.web.context.WebApplicationContext"%> -<% -WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(application); -%> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_form.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_form.jsp deleted file mode 100644 index 85e1474d..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_form.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.util.WebUtils" %> -<%-- -表单页面JS片段。 - -依赖: -page_js_obj.jsp ---%> - diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/login.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/login.jsp deleted file mode 100644 index cdaf6cb1..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/login.jsp +++ /dev/null @@ -1,133 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.springframework.security.core.Authentication" %> -<%@ page import="org.springframework.security.core.AuthenticationException" %> -<%@ page import="org.springframework.security.web.WebAttributes" %> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_method_get_string_value.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/html_doctype.jsp" %> -<% -String loginUser = (String)session.getAttribute(org.datagear.web.controller.RegisterController.SESSION_KEY_REGISTER_USER_NAME); - -//参考org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler.saveException() -AuthenticationException authenticationException = (AuthenticationException)request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); -if(authenticationException != null) -{ - request.getSession().removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); - - Authentication authentication = authenticationException.getAuthentication(); - - if(authentication != null && authentication.getPrincipal() != null) - loginUser = authentication.getPrincipal().toString(); -} - -if(loginUser == null) - loginUser = ""; -%> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='login.login' /> - - -
-
- <%@ include file="include/html_logo.jsp" %> -
- - "> - - "> -
-
- -
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/register_success.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/register_success.jsp deleted file mode 100644 index cbc31403..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/register_success.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/html_doctype.jsp" %> -<% -String loginUrl = request.getContextPath() + "/login"; -%> - - -<%@ include file="include/html_head.jsp" %> - -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='register.registerSuccess' /> - - -
-
- <%@ include file="include/html_logo.jsp" %> -
- "> -
-
-
-
- - - -
-
-
- - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password.jsp deleted file mode 100644 index 863a8049..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password.jsp +++ /dev/null @@ -1,252 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.controller.ResetPasswordController" %> -<%@ page import="org.datagear.web.controller.ResetPasswordController.ResetPasswordStep" %> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/jsp_method_get_string_value.jsp" %> -<%@ include file="include/html_doctype.jsp" %> -<%! -protected String getStepClass(ResetPasswordStep currentStep, int step) -{ - if(currentStep.isAfter(step)) - return " ui-state-default"; - else if(currentStep.isStep(step)) - return " ui-state-active"; - else - return " ui-state-disabled"; -} -%> -<% -ResetPasswordStep step = (ResetPasswordStep)session.getAttribute(ResetPasswordController.KEY_STEP); -String formAction = request.getContextPath() + "/resetPassword/" + step.getAction(); - -String loginUrl = request.getContextPath() + "/login"; -%> - - -<%@ include file="include/html_head.jsp" %> -<%if(step.isFinalStep() && !step.isSkipCheckUserAdmin()){%> - -<%}%> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='resetPassword.resetPassword' /> - - -
-
- <%@ include file="include/html_logo.jsp" %> -
- - "> - "> -
-
-
-
- -
-
-
-
-
-
-
-
-
-
- <%if(step.isStep(1)){%> -
-
- -
-
- -
-
- <%}else if(step.isStep(2)){%> -
-
- -
-
- -
-
-
-
- -
-
- - -
-
-
-
- -
-
- -
-
- <%}else if(step.isStep(3)){%> -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
- <%if(step.isSkipCheckUserAdmin()){%> -
-
- - - - -
-
- <%}%> - <%}else if(step.isFinalStep()){%> -
- - <%if(step.isSkipCheckUserAdmin()){%> - - - - - <%}else{%> - - - - <%}%> -
- <%}%> -
-
- disabled="disabled"<%}%> /> - disabled="disabled"<%}else{%> class="recommended"<%}%> /> -
-
-
-
-
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password_request_history.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password_request_history.jsp deleted file mode 100644 index 3cccda2c..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/reset_password_request_history.jsp +++ /dev/null @@ -1,87 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/jsp_method_get_string_value.jsp" %> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='resetPasswordRequestHistory.resetPasswordRequestHistory' /> - - -<%if(!ajaxRequest){%> -
-<%}%> -
-
- -
-
-
-
- -
-
-
-
- -
-
-
-<%if(!ajaxRequest){%> -
-<%}%> -<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_searchform_js.jsp" %> -<%@ include file="include/page_obj_pagination.jsp" %> -<%@ include file="include/page_obj_grid.jsp" %> - - - diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/schema_url_builder.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/schema_url_builder.jsp deleted file mode 100644 index b3242909..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/schema_url_builder.jsp +++ /dev/null @@ -1,104 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/jsp_method_get_string_value.jsp" %> -<%@ include file="include/html_doctype.jsp" %> - - -<%@ include file="include/html_head.jsp" %> -<%@ include file="include/html_title_app_name.jsp" %><fmt:message key='schemaUrlBuilder.schemaUrlBuilder' /> - - -
-
-
-
-
-
- -
-
- -
- -
-{
-   //
-   dbType : "...",
-   
-   //
-   template : "...{host}...{port}...{name}...",
-   
-   //
-   defaultValue : { host : "...", port : "...", name : "" },
-   
-   //
-   order : 6
-}
- -
-
-
-
-
- -
-
- -
-
-
-
- -    - -
-
-
-<%@ include file="include/page_js_obj.jsp" %> -<%@ include file="include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_form.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_form.jsp deleted file mode 100644 index cc7ea186..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_form.jsp +++ /dev/null @@ -1,176 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.controller.UserController" %> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//标题标签I18N关键字,不允许null -String titleMessageKey = getStringValue(request, UserController.KEY_TITLE_MESSAGE_KEY); -//表单提交action,允许为null -String formAction = getStringValue(request, UserController.KEY_FORM_ACTION, "#"); -//是否只读操作,允许为null -boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, UserController.KEY_READONLY))); - -boolean isAdd = "saveAdd".equals(formAction); -%> - - -<%@ include file="../include/html_head.jsp" %> -<%@ include file="../include/html_title_app_name.jsp" %><fmt:message key='<%=titleMessageKey%>' /> - - -
-
-
-
- -
-
- -
-
- -
-
- <%if(!readonly){%> -
-
- -
-
- -
-
-
-
- -
-
- -
-
- <%}%> -
-
- -
-
- -
-
-
-
- -
-
- -
-
- <%--禁用新建管理员账号功能 -
-
- -
-
-
- - checked="checked" /> - - checked="checked" /> -
-
-
- --%> -
-
- <%if(!readonly){%> - -    - - <%}%> -
-
-
-<%@ include file="../include/page_js_obj.jsp" %> -<%@ include file="../include/page_obj_form.jsp" %> - - - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_grid.jsp b/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_grid.jsp deleted file mode 100644 index 0b501c58..00000000 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/user/user_grid.jsp +++ /dev/null @@ -1,200 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.controller.AbstractController" %> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//标题标签I18N关键字,不允许null -String titleMessageKey = getStringValue(request, AbstractController.KEY_TITLE_MESSAGE_KEY); -//是否选择操作,允许为null -boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, AbstractController.KEY_SELECTONLY))); -%> - - -<%@ include file="../include/html_head.jsp" %> -<%@ include file="../include/html_title_app_name.jsp" %><fmt:message key='<%=titleMessageKey%>' /> - - -<%if(!ajaxRequest){%> -
-<%}%> -
-
- -
- <%if(selectonly){%> - - - <%}else{%> - - - - - <%}%> -
-
-
- -
-
-
-
- -
-
-
-<%if(!ajaxRequest){%> -
-<%}%> -<%@ include file="../include/page_js_obj.jsp" %> -<%@ include file="../include/page_obj_searchform_js.jsp" %> -<%@ include file="../include/page_obj_grid.jsp" %> - - - diff --git a/datagear-web/src/main/webapp/WEB-INF/view/about.ftl b/datagear-web/src/main/webapp/WEB-INF/view/about.ftl new file mode 100644 index 00000000..5fac7959 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/about.ftl @@ -0,0 +1,48 @@ +<#include "include/import_global.ftl"> +<#include "include/html_doctype.ftl"> + + +<#include "include/html_head.ftl"> +<#include "include/html_title_app_name.ftl"><@spring.message code='about.about' /> + + +
+
+
+
+
+ +
+
+ <@spring.message code='app.name' /> +
+
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+<#include "include/page_js_obj.ftl" > +<#include "include/page_obj_form.ftl"> + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/change_theme_data.ftl b/datagear-web/src/main/webapp/WEB-INF/view/change_theme_data.ftl new file mode 100644 index 00000000..308d2437 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/change_theme_data.ftl @@ -0,0 +1,18 @@ +<#include "include/import_global.ftl"> +[ + { + "selector" : "#css_jquery_ui", + "attr" : "href", + "value" : "${contextPath}/static/theme/<@spring.theme code='theme' />/jquery-ui-1.12.1/jquery-ui.css" + }, + { + "selector" : "#css_jquery_ui_theme", + "attr" : "href", + "value" : "${contextPath}/static/theme/<@spring.theme code='theme' />/jquery-ui-1.12.1/jquery-ui.theme.css" + }, + { + "selector" : "#css_common", + "attr" : "href", + "value" : "${contextPath}/static/theme/<@spring.theme code='theme' />/common.css" + } +] \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/changelog.ftl b/datagear-web/src/main/webapp/WEB-INF/view/changelog.ftl new file mode 100644 index 00000000..fbf14095 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/changelog.ftl @@ -0,0 +1,64 @@ +<#include "include/import_global.ftl"> +<#include "include/html_doctype.ftl"> + + +<#include "include/html_head.ftl"> +<#include "include/html_title_app_name.ftl"><@spring.message code='changelog.changelog' /> + + +
+ <#if !isAjaxRequest> +
+ <#include "include/html_logo.ftl"> +
+ +
+
+
+ <#list versionChangelogs as versionChangelog> +
+
+ +
+
+ ${versionChangelog.version} +
+
+
+
+ +
+
+
    + <#list versionChangelog.contents as item> +
  • ${item?html}
  • + +
+
+
+ +
+
+ <#if !(allListed??) || allListed == false> + <@spring.message code='changelog.viewAll' /> + +
+
+
+
+<#include "include/page_js_obj.ftl" > +<#include "include/page_obj_form.ftl"> + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_form.jsp b/datagear-web/src/main/webapp/WEB-INF/view/data/data_form.ftl similarity index 58% rename from datagear-web/src/main/webapp/WEB-INF/jsp/data/data_form.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/data/data_form.ftl index 68ae22d4..513d3ae9 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_form.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/data/data_form.ftl @@ -1,41 +1,31 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/jsp_method_write_json.jsp" %> -<%@ include file="include/data_jsp_define.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//初始数据,允许null -Object data = request.getAttribute("data"); -//初始数据是否是客户端数据,默认为false -boolean isClientPageData = ("true".equalsIgnoreCase(getStringValue(request, "isClientPageData"))); -//标题操作标签I18N关键字,不允许null -String titleOperationMessageKey = getStringValue(request, "titleOperationMessageKey"); -//提交活动,po.pageParam().submit(...)未定义时,不允许为null -String submitAction = getStringValue(request, "submitAction"); -//是否只读操作,默认为false -boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, "readonly"))); -//忽略表单渲染和处理的属性名,默认为"" -String ignorePropertyName = getStringValue(request, "ignorePropertyName", ""); -//是否开启批量执行功能,默认为false -boolean batchSet = ("true".equalsIgnoreCase(getStringValue(request, "batchSet"))); -%> +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +Schema schema 数据库,不允许为null +Model model 模型,不允许为null +Object data 初始数据,允许null +boolean isClientPageData 初始数据是否是客户端数据,默认为false +String titleOperationMessageKey 标题操作标签I18N关键字,不允许null +String titleDisplayName 页面展示名称,默认为"" +String submitAction 提交活动,po.pageParam().submit(...)未定义时,不允许为null +boolean readonly 是否只读操作,默认为false +String ignorePropertyName 忽略表单渲染和处理的属性名,默认为"" +boolean batchSet 是否开启批量执行功能,默认为false +--> +<#assign isClientPageData=(isClientPageData!false)> +<#assign titleDisplayName=(titleDisplayName!'')> +<#assign submitAction=(submitAction!'#')> +<#assign readonly=(readonly!false)> +<#assign ignorePropertyName=(ignorePropertyName!'')> +<#assign batchSet=(batchSet!false)> -<%@ include file="../include/html_head.jsp" %> +<#include "../include/html_head.ftl"> - <%@ include file="../include/html_title_app_name.jsp" %> - <fmt:message key='<%=titleOperationMessageKey%>' /> - <fmt:message key='titleSeparator' /> - <%=WebUtils.escapeHtml(ModelUtils.displayName(model, WebUtils.getLocale(request)))%> + <#include "../include/html_title_app_name.ftl"> + <@spring.message code='${titleOperationMessageKey}' /> + <@spring.message code='titleSeparator' /> + ${titleDisplayName?html} @@ -49,16 +39,16 @@ boolean batchSet = ("true".equalsIgnoreCase(getStringValue(request, "batchSet"))
-<%@ include file="include/data_page_obj.jsp" %> -<%@ include file="include/data_page_obj_form.jsp" %> +<#include "include/data_page_obj.ftl"> +<#include "include/data_page_obj_form.ftl"> + + diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_prop_value_form.jsp b/datagear-web/src/main/webapp/WEB-INF/view/data/data_prop_value_form.ftl similarity index 61% rename from datagear-web/src/main/webapp/WEB-INF/jsp/data/data_prop_value_form.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/data/data_prop_value_form.ftl index f0e1d2e6..7773fcd0 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/data/data_prop_value_form.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/data/data_prop_value_form.ftl @@ -1,45 +1,31 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/jsp_method_write_json.jsp" %> -<%@ include file="include/data_jsp_define.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//初始数据,允许null -Object data = request.getAttribute("data"); -//属性名称,不允许null -String propertyPath = getStringValue(request, "propertyPath"); -//初始属性值,可用于设置初始表单数据,允许为null -Object propertyValue = request.getAttribute("propertyValue"); -//初始属性值数据是否是客户端数据,默认为false -boolean isClientPageData = ("true".equalsIgnoreCase(getStringValue(request, "isClientPageData"))); -//标题操作标签I18N关键字,不允许null -String titleOperationMessageKey = getStringValue(request, "titleOperationMessageKey"); -//提交活动,po.pageParam().submit(...)未定义时,不允许为null -String submitAction = getStringValue(request, "submitAction"); -//是否只读操作,默认为false -boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, "readonly"))); -//是否开启批量执行功能,默认为false -boolean batchSet = ("true".equalsIgnoreCase(getStringValue(request, "batchSet"))); - -PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath); -%> +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +Schema schema 数据库,不允许为null +Model model 模型,不允许为null +Object data 初始数据,允许null +String propertyPath 属性名称,不允许null +Object propertyValue 初始属性值,可用于设置初始表单数据,允许为null +boolean isClientPageData 初始数据是否是客户端数据,默认为false +String titleOperationMessageKey 标题操作标签I18N关键字,不允许null +String titleDisplayName 页面展示名称,默认为"" +String submitAction 提交活动,po.pageParam().submit(...)未定义时,不允许为null +boolean readonly 是否只读操作,默认为false +boolean batchSet 是否开启批量执行功能,默认为false +--> +<#assign isClientPageData=(isClientPageData!false)> +<#assign titleDisplayName=(titleDisplayName!'')> +<#assign submitAction=(submitAction!'#')> +<#assign readonly=(readonly!false)> +<#assign batchSet=(batchSet!false)> -<%@ include file="../include/html_head.jsp" %> +<#include "../include/html_head.ftl"> - <%@ include file="../include/html_title_app_name.jsp" %> - <fmt:message key='<%=titleOperationMessageKey%>' /> - <fmt:message key='titleSeparator' /> - <%=WebUtils.escapeHtml(ModelUtils.displayName(model, propertyPathObj, WebUtils.getLocale(request)))%> + <#include "../include/html_title_app_name.ftl"> + <@spring.message code='${titleOperationMessageKey}' /> + <@spring.message code='titleSeparator' /> + ${titleDisplayName?html} @@ -53,18 +39,18 @@ PropertyPath propertyPathObj = ModelUtils.toPropertyPath(propertyPath);
-<%@ include file="include/data_page_obj.jsp" %> -<%@ include file="include/data_page_obj_form.jsp" %> +<#include "include/data_page_obj.ftl"> +<#include "include/data_page_obj_form.ftl"> -<% -WebUtils.setPageId(request, gridPageId); -%> +<#assign pageId=gridPageId> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/driverEntity/driverEntity_grid.jsp b/datagear-web/src/main/webapp/WEB-INF/view/driverEntity/driverEntity_grid.ftl similarity index 52% rename from datagear-web/src/main/webapp/WEB-INF/jsp/driverEntity/driverEntity_grid.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/driverEntity/driverEntity_grid.ftl index 9d453377..969d622b 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/driverEntity/driverEntity_grid.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/driverEntity/driverEntity_grid.ftl @@ -1,48 +1,36 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.controller.DriverEntityController" %> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -//标题标签I18N关键字,不允许null -String titleMessageKey = getStringValue(request, DriverEntityController.KEY_TITLE_MESSAGE_KEY); -//是否选择操作,允许为null -boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEntityController.KEY_SELECTONLY))); -%> +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +titleMessageKey 标题标签I18N关键字,不允许null +selectonly 是否选择操作,允许为null +--> +<#assign selectonly=(selectonly!false)> -<%@ include file="../include/html_head.jsp" %> -<%@ include file="../include/html_title_app_name.jsp" %><fmt:message key='<%=titleMessageKey%>' /> +<#include "../include/html_head.ftl"> +<#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> -<%if(!ajaxRequest){%> +<#if !isAjaxRequest>
-<%}%> +
- <%if(selectonly){%> - - - <%}else{%> - - - - - - - <%}%> + <#if selectonly> + + + <#else> + + + + + + +
@@ -55,12 +43,12 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEnti
-<%if(!ajaxRequest){%> +<#if !isAjaxRequest> -<%}%> -<%@ include file="../include/page_js_obj.jsp" %> -<%@ include file="../include/page_obj_searchform_js.jsp" %> -<%@ include file="../include/page_obj_grid.jsp" %> + +<#include "../include/page_js_obj.ftl"> +<#include "../include/page_obj_searchform_js.ftl"> +<#include "../include/page_obj_grid.ftl"> + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/include/html_doctype.ftl b/datagear-web/src/main/webapp/WEB-INF/view/include/html_doctype.ftl new file mode 100644 index 00000000..bb54ee51 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/html_doctype.ftl @@ -0,0 +1 @@ +<#if !isAjaxRequest> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/include/html_head.ftl b/datagear-web/src/main/webapp/WEB-INF/view/include/html_head.ftl new file mode 100644 index 00000000..db5d64b2 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/html_head.ftl @@ -0,0 +1,38 @@ + + + +<#if !isAjaxRequest> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/include/html_logo.ftl b/datagear-web/src/main/webapp/WEB-INF/view/include/html_logo.ftl new file mode 100644 index 00000000..bf2b6e7a --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/html_logo.ftl @@ -0,0 +1,3 @@ + diff --git a/datagear-web/src/main/webapp/WEB-INF/view/include/html_title_app_name.ftl b/datagear-web/src/main/webapp/WEB-INF/view/include/html_title_app_name.ftl new file mode 100644 index 00000000..a9acd533 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/html_title_app_name.ftl @@ -0,0 +1 @@ +<#if !isAjaxRequest><@spring.message code='app.name' /> - \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/include/import_global.ftl b/datagear-web/src/main/webapp/WEB-INF/view/include/import_global.ftl new file mode 100644 index 00000000..28ed8a46 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/import_global.ftl @@ -0,0 +1 @@ +<#import "/spring.ftl" as spring /> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_js_obj.jsp b/datagear-web/src/main/webapp/WEB-INF/view/include/page_js_obj.ftl similarity index 79% rename from datagear-web/src/main/webapp/WEB-INF/jsp/include/page_js_obj.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/include/page_js_obj.ftl index c553a4c3..437ecea7 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_js_obj.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/page_js_obj.ftl @@ -1,16 +1,9 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="org.datagear.web.util.WebUtils" %> -<%--页面JS对象块 --%> +<#--页面JS对象块 --> diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_grid.jsp b/datagear-web/src/main/webapp/WEB-INF/view/include/page_obj_grid.ftl similarity index 91% rename from datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_grid.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/include/page_obj_grid.ftl index c36921e7..f3c60d74 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/include/page_obj_grid.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/include/page_obj_grid.ftl @@ -1,15 +1,9 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%-- +<#-- 表格JS片段。 依赖: page_js_obj.jsp ---%> +--> + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/main.jsp b/datagear-web/src/main/webapp/WEB-INF/view/main.ftl similarity index 80% rename from datagear-web/src/main/webapp/WEB-INF/jsp/main.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/main.ftl index dfcda5de..5a971a1a 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/main.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/main.ftl @@ -1,31 +1,21 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="include/jsp_import.jsp" %> -<%@ include file="include/jsp_ajax_request.jsp" %> -<%@ include file="include/jsp_jstl.jsp" %> -<%@ include file="include/jsp_page_id.jsp" %> -<%@ include file="include/html_doctype.jsp" %> +<#include "include/import_global.ftl"> +<#include "include/html_doctype.ftl"> -<%@ include file="include/html_head.jsp" %> -<fmt:message key='app.name' /> -<%@ include file="include/page_js_obj.jsp" %> +<#include "include/html_head.ftl"> +<@spring.message code='app.name' /> +<#include "include/page_js_obj.ftl" > + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/reset_password_request_history.ftl b/datagear-web/src/main/webapp/WEB-INF/view/reset_password_request_history.ftl new file mode 100644 index 00000000..0390fa55 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/reset_password_request_history.ftl @@ -0,0 +1,77 @@ +<#include "include/import_global.ftl"> +<#include "include/html_doctype.ftl"> + + +<#include "include/html_head.ftl"> +<#include "include/html_title_app_name.ftl"><@spring.message code='resetPasswordRequestHistory.resetPasswordRequestHistory' /> + + +<#if !isAjaxRequest> +
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+<#if !isAjaxRequest> +
+ +<#include "include/page_js_obj.ftl"> +<#include "include/page_obj_searchform_js.ftl"> +<#include "include/page_obj_pagination.ftl"> +<#include "include/page_obj_grid.ftl"> + + + diff --git a/datagear-web/src/main/webapp/WEB-INF/jsp/schema/schema_build_url.jsp b/datagear-web/src/main/webapp/WEB-INF/view/schema/schema_build_url.ftl similarity index 67% rename from datagear-web/src/main/webapp/WEB-INF/jsp/schema/schema_build_url.jsp rename to datagear-web/src/main/webapp/WEB-INF/view/schema/schema_build_url.ftl index 4321e856..e0d25a5d 100644 --- a/datagear-web/src/main/webapp/WEB-INF/jsp/schema/schema_build_url.jsp +++ b/datagear-web/src/main/webapp/WEB-INF/view/schema/schema_build_url.ftl @@ -1,36 +1,25 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ include file="../include/jsp_import.jsp" %> -<%@ include file="../include/jsp_ajax_request.jsp" %> -<%@ include file="../include/jsp_jstl.jsp" %> -<%@ include file="../include/jsp_method_get_string_value.jsp" %> -<%@ include file="../include/jsp_page_id.jsp" %> -<%@ include file="../include/html_doctype.jsp" %> -<% -boolean isPreview = "1".equals(getStringValue(request, "preview")); -%> +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +preview 是否是预览请求,允许为null +--> +<#assign preview=(preview!false)> -<%@ include file="../include/html_head.jsp" %> -<%@ include file="../include/html_title_app_name.jsp" %><fmt:message key='schema.schemaBuildUrl' /> +<#include "../include/html_head.ftl"> +<#include "../include/html_title_app_name.ftl"><@spring.message code='schema.schemaBuildUrl' />
- +
@@ -47,7 +36,7 @@ boolean isPreview = "1".equals(getStringValue(request, "preview"));
- +
@@ -55,7 +44,7 @@ boolean isPreview = "1".equals(getStringValue(request, "preview"));
- +
@@ -63,21 +52,21 @@ boolean isPreview = "1".equals(getStringValue(request, "preview"));
- +
- <%if(isPreview){%> + <#if preview>
- <%}%> +
-<%@ include file="../include/page_js_obj.jsp" %> -<%@ include file="../include/page_obj_form.jsp" %> +<#include "../include/page_js_obj.ftl" > +<#include "../include/page_obj_form.ftl"> diff --git a/datagear-web/src/main/webapp/WEB-INF/view/schema_url_builder.ftl b/datagear-web/src/main/webapp/WEB-INF/view/schema_url_builder.ftl new file mode 100644 index 00000000..354e3c90 --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/schema_url_builder.ftl @@ -0,0 +1,94 @@ +<#include "include/import_global.ftl"> +<#include "include/html_doctype.ftl"> + + +<#include "include/html_head.ftl"> +<#include "include/html_title_app_name.ftl"><@spring.message code='schemaUrlBuilder.schemaUrlBuilder' /> + + +
+
+
+
+
+
+ +
+
+ +
+ <@spring.message code='schemaUrlBuilder.scriptCodeNote.0' /> +
+{
+   //<@spring.message code='schemaUrlBuilder.scriptCodeNote.required' /><@spring.message code='comma' /><@spring.message code='schemaUrlBuilder.scriptCodeNote.dbType' />
+   dbType : "...",
+   
+   //<@spring.message code='schemaUrlBuilder.scriptCodeNote.required' /><@spring.message code='comma' /><@spring.message code='schemaUrlBuilder.scriptCodeNote.template' />
+   template : "...{host}...{port}...{name}...",
+   
+   //<@spring.message code='schemaUrlBuilder.scriptCodeNote.optional' /><@spring.message code='comma' /><@spring.message code='schemaUrlBuilder.scriptCodeNote.defaultValue' />
+   defaultValue : { host : "...", port : "...", name : "" },
+   
+   //<@spring.message code='schemaUrlBuilder.scriptCodeNote.optional' /><@spring.message code='comma' /><@spring.message code='schemaUrlBuilder.scriptCodeNote.order' />
+   order : 6
+}
+ <@spring.message code='schemaUrlBuilder.scriptCodeNote.1' /> +
+
+
+
+
+ +
+
+ +
+
+
+
+ +    + +
+
+
+<#include "include/page_js_obj.ftl"> +<#include "include/page_obj_form.ftl"> + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/user/user_form.ftl b/datagear-web/src/main/webapp/WEB-INF/view/user/user_form.ftl new file mode 100644 index 00000000..8e9a212b --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/user/user_form.ftl @@ -0,0 +1,164 @@ +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +titleMessageKey 标题标签I18N关键字,不允许null +formAction 表单提交action,允许为null +readonly 是否只读操作,允许为null +--> +<#assign formAction=(formAction!'#')> +<#assign readonly=(readonly!false)> +<#assign isAdd=(formAction == 'saveAdd')> + + +<#include "../include/html_head.ftl"> +<#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> + + +
+
+
+
+ +
+
+ +
+
+ +
+
+ <#if !readonly> +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ <#-- + 禁用新建管理员账号功能 +
+
+ +
+
+
+ + checked="checked" /> + + checked="checked" /> +
+
+
+ --> +
+
+ <#if !readonly> + +    + + +
+
+
+<#include "../include/page_js_obj.ftl" > +<#include "../include/page_obj_form.ftl"> + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/WEB-INF/view/user/user_grid.ftl b/datagear-web/src/main/webapp/WEB-INF/view/user/user_grid.ftl new file mode 100644 index 00000000..4857f5df --- /dev/null +++ b/datagear-web/src/main/webapp/WEB-INF/view/user/user_grid.ftl @@ -0,0 +1,188 @@ +<#include "../include/import_global.ftl"> +<#include "../include/html_doctype.ftl"> +<#-- +titleMessageKey 标题标签I18N关键字,不允许null +selectonly 是否选择操作,允许为null +--> +<#assign selectonly=(selectonly!false)> + + +<#include "../include/html_head.ftl"> +<#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> + + +<#if !isAjaxRequest> +
+ +
+
+ +
+ <#if selectonly> + + + <#else> + + + + + +
+
+
+ +
+
+
+
+ +
+
+
+<#if !isAjaxRequest> +
+ +<#include "../include/page_js_obj.ftl"> +<#include "../include/page_obj_searchform_js.ftl"> +<#include "../include/page_obj_grid.ftl"> + + + diff --git a/datagear-web/src/main/webapp/WEB-INF/web.xml b/datagear-web/src/main/webapp/WEB-INF/web.xml index 37ceb851..8f45a4c9 100644 --- a/datagear-web/src/main/webapp/WEB-INF/web.xml +++ b/datagear-web/src/main/webapp/WEB-INF/web.xml @@ -77,6 +77,7 @@ dispatcherServlet + /index.html /login/* /register/* /main/* @@ -97,7 +98,7 @@ - index.jsp + index.html diff --git a/datagear-web/src/main/webapp/index.html b/datagear-web/src/main/webapp/index.html new file mode 100644 index 00000000..69e229f7 --- /dev/null +++ b/datagear-web/src/main/webapp/index.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/datagear-web/src/main/webapp/index.jsp b/datagear-web/src/main/webapp/index.jsp deleted file mode 100644 index ab8e138b..00000000 --- a/datagear-web/src/main/webapp/index.jsp +++ /dev/null @@ -1,9 +0,0 @@ -<%-- -/* - * Copyright 2018 datagear.tech. All Rights Reserved. - */ ---%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<% -request.getRequestDispatcher("/main").forward(request, response); -%> \ No newline at end of file diff --git a/datagear-web/src/main/webapp/static/script/datagear-model.js b/datagear-web/src/main/webapp/static/script/datagear-model.js index 76a7f473..873ace61 100644 --- a/datagear-web/src/main/webapp/static/script/datagear-model.js +++ b/datagear-web/src/main/webapp/static/script/datagear-model.js @@ -702,6 +702,50 @@ } }, + /** + * 获取/设置对象属性值。 + */ + modelPropertyValue : function(model, property, obj, propertyValue) + { + if(model == null || property == null || obj == null) + throw new Error("[model], [property], [obj] must be defined"); + + var isGet = (arguments.length == 2); + + if(isGet) + return obj[property.name]; + else + { + if(propertyValue == null) + obj[property.name] = propertyValue; + else + { + var propertyModel = this.getPropertyModelByValue(property, propertyValue); + var mappedWithPropertyName = this.findMappedByWith(property, propertyModel); + + if(mappedWithPropertyName) + { + //反向赋值 + if(this.isMultipleProperty(property)) + { + var length = (propertyValue.length ? propertyValue.length : 0); + for(var i=0; i