- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Spring 框架创建一个项目,并使用 Spring MVC 框架来构建我的 View 。
现在一切工作正常并且运行顺利,除了这个简单的 GET 页面需要 2 秒甚至更多的时间才能在本地主机上加载。
正如您在日志(链接)中看到的那样,GenericConversionService 尝试查找转换器来绑定(bind)属性,速度非常慢。
非常感谢您的帮助!
提前致谢(对我的拼写错误表示歉意):)
更新:
显然,转换服务针对“http://www.springframework.org/tags/form ”命名空间中的每个(与 Path 属性绑定(bind))表单标签运行。我使用的表单标签越多,页面加载速度就越慢。我应该使用普通的 html 表单标签来提高性能还是有办法阻止它寻找“正确的”转换器?
其他信息:
日志: Link (滚动大约 1/3,您将看到大量 GenericConversionService 日志
Spring Insight 分析信息:
Controller (马虎)代码:
@RequestMapping(value = "/route/create", method = RequestMethod.GET)
public ModelAndView getCreateRoute(){
RouteCreateUpdateViewModel result = new RouteCreateUpdateViewModel();
User u = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
u = us.get(u.getId());
ModelAndView mav = new ModelAndView("route/create", "routeCreateUpdateModel", result);
mav.addObject("favLocations", u.getLocations());
mav.addObject("cars", u.getCars());
result.setDateDay(Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + 1); // January = 0
result.setDateMonth(Calendar.getInstance().get(Calendar.MONTH));
result.setDateYear(Calendar.getInstance().get(Calendar.YEAR));
mav.addObject("nextYear", result.getDateYear() + 1);
return mav;
}
查看代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!-- //TODO I18N -->
<style type="text/css">
li:focus {
background-color:green;
}
</style>
<script>
var highlightedElement = null;
$(document).ready(function(){
$("input,select").click(function() {
if(highlightedElement != null)
{
$(highlightedElement).removeClass("curFocus");
if(highlightedElement.hasClass("location"))
{
checkLocation(highlightedElement);
}
}
var newHighlightedElement = $(this).parent().parent();
$(newHighlightedElement).addClass("curFocus");
highlightedElement = newHighlightedElement;
});
});
function checkLocation(highlightedElement)
{
var parameters = {
zipcode: $(highlightedElement).find(".zipcode").val(),
street: $(highlightedElement).find(".street").val(),
streetNr: $(highlightedElement).find(".streetNr").val()
};
$.getJSON('/location/validate.php', parameters, function(data) {
if(data.result != null)
{
$(highlightedElement).removeClass("badData");
$(highlightedElement).addClass("goodData");
}
else {
$(highlightedElement).removeClass("goodData")
$(highlightedElement).addClass("badData");
}
});
}
</script>
<div>
<h1><fmt:message key="route.create.header"/></h1>
<div class="form-container">
<c:url value="/route/create.php" var="actUrl"/>
<form:form method="POST" action="${actUrl}" modelAttribute="routeCreateUpdateModel">
<ul>
<li class="location">
<form:label path="fromZipcode" cssClass="title">Van<span class="required">*</span></form:label>
<span>
<form:input path="fromZipcode" cssClass="zipcode"/>
<form:label path="fromZipcode" cssClass="desc">Gemeente</form:label>
</span>
<span>
<form:input path="fromStreet" cssClass="street"/>
<form:label path="fromStreet" cssClass="desc">Straat</form:label>
</span>
<span>
<form:input path="fromStreetNr" cssClass="streetNr"/>
<form:label path="fromStreetNr" cssClass="desc">Nr</form:label>
</span>
</li>
<li class="location">
<form:label path="toZipcode" cssClass="title">Naar<span class="required">*</span></form:label>
<span>
<form:input path="toZipcode" cssClass="zipcode"/>
<form:label path="toZipcode" cssClass="desc">Gemeente</form:label>
</span>
<span>
<form:input path="toStreet" cssClass="street"/>
<form:label path="toStreet" cssClass="desc">Straat</form:label>
</span>
<span>
<form:input path="toStreetNr" cssClass="streetNr"/>
<form:label path="toStreetNr" cssClass="desc">Nr</form:label>
</span>
</li>
<li>
<form:label path="dateDay" cssClass="title">Datum<span class="required">*</span></form:label>
<span>
<tags:showDayPicker path="dateDay" currentDay="${routeCreateUpdateModel.dateDay}"/>
<form:label path="dateDay" cssClass="desc">dd</form:label>
</span>
<span>
<tags:showMonthPicker path="dateMonth" currentMonth="${routeCreateUpdateModel.dateMonth}"/>
<form:label path="dateMonth" cssClass="desc">mm</form:label>
</span>
<span>
<tags:showYearPicker path="dateYear" startYear="${routeCreateUpdateModel.dateYear}"
stopYear="${nextYear}"/>
<form:label path="dateYear" cssClass="desc">yyyy</form:label>
</span>
</li>
<li>
<form:label path="days" cssClass="title">Dagen<span class="required">*</span></form:label>
<span>
<form:checkbox path="days" value="1"/>
<form:label path="days" cssClass="desc">Ma</form:label>
</span>
<span>
<form:checkbox path="days" value="2"/>
<form:label path="days" cssClass="desc">Di</form:label>
</span>
<span>
<form:checkbox path="days" value="3"/>
<form:label path="days" cssClass="desc">Wo</form:label>
</span>
<span>
<form:checkbox path="days" value="4"/>
<form:label path="days" cssClass="desc">Do</form:label>
</span>
<span>
<form:checkbox path="days" value="5"/>
<form:label path="days" cssClass="desc">Vrij</form:label>
</span>
<span>
<form:checkbox path="days" value="6"/>
<form:label path="days" cssClass="desc">Za</form:label>
</span>
<span>
<form:checkbox path="days" value="7"/>
<form:label path="days" cssClass="desc">Zo</form:label>
</span>
</li>
<li>
<form:label path="stopDateDay" cssClass="title">Herhalen tot<span class="required">*</span></form:label>
<span>
<tags:showDayPicker path="stopDateDay" currentDay="${routeCreateUpdateModel.dateDay}"/>
<form:label path="stopDateDay" cssClass="desc">dd</form:label>
</span>
<span>
<tags:showMonthPicker path="stopDateMonth" currentMonth="${routeCreateUpdateModel.dateMonth}"/>
<form:label path="stopDateMonth" cssClass="desc">mm</form:label>
</span>
<span>
<tags:showYearPicker path="stopDateYear" startYear="${routeCreateUpdateModel.dateYear}"
stopYear="${nextYear}"/>
<form:label path="stopDateYear" cssClass="desc">yyyy</form:label>
</span>
</li>
<li>
<form:label path="departureTime" cssClass="title">Vertrek uur<span class="required">*</span></form:label>
<span>
<tags:showHourPicker path="departureTime"/>
<form:label path="departureTime" cssClass="desc">uu</form:label>
</span>
<span>
<tags:showMinutePicker path="departureTime"/>
<form:label path="departureTime" cssClass="desc">mm</form:label>
</span>
</li>
<li>
<form:label path="arrivalTime" cssClass="title">Aankomst uur<span class="required">*</span></form:label>
<span>
<tags:showHourPicker path="arrivalTime"/>
<form:label path="arrivalTime" cssClass="desc">uu</form:label>
</span>
<span>
<tags:showMinutePicker path="arrivalTime"/>
<form:label path="arrivalTime" cssClass="desc">mm</form:label>
</span>
</li>
<li>
<form:label path="car" cssClass="title">Auto</form:label>
<span>
<form:select path="car">
<form:options items="${cars}" itemLabel="carName" itemValue="Id" />
</form:select>
</span>
</li>
</ul>
<input type="submit" value="Route toevoegen"/>
</form:form>
</div>
</div>
如果您需要更多信息,请询问,我会立即提供。
再次感谢:)
最佳答案
问题可能是由 <form:option>
中的类型转换次数过多引起的标签。
对于不需要类型转换的简单值,您可以使用 HTML <option>
按原样标记:
<form:select path="${path}">
<c:forEach var="i" begin="0" end="59" step="${interval}">
<option value="${i}"><fmt:formatNumber value="${i}" minIntegerDigits="2" /></option>
</c:forEach>
</form:select>
作为更积极的优化,您可以摆脱 <c:forEach>
和<fmt:formatNumber>
并填充 <form:select>
的正文使用预先生成的 HTML。
关于Spring Web MVC 渲染 View 时存在巨大的性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5246685/
我通过在共享首选项中使用 GSON 将其转换为 json 来存储我的复杂对象。但是在检索它时,无法获得预期的字符串。 代码 这里 holderListCustomizationMap 是对象的复杂映射
因此,我正在尝试对大于可用RAM的gz压缩文件执行某种面向行的操作,因此排除了将其首先读取为字符串的情况。问题是,如何在rust(缺少gunzip file.gz|./my-rust-program)
我试图更好地理解为什么具有潜在大精度的大数字处理不一致,特别是在 JavaScript 及其本地化工具(例如 ECMA-402/Intl)中。我假设这与 float 的使用有关,但我想了解限制在哪里和
我们有一个 5GB 的 csv 文件,这是我们业务的主列表。 有多个类别,每个类别包含数千条记录。我们的目标是将每个类别导出为其自己的 csv 文件。 我们如何运行查询并导出数据? 运行 OSX。有没
基于上一个问题 ( see here ),我试图通过 xmlEventParse 读取许多大型 xml 文件,同时保存节点变化数据。使用此示例 xml:https://www.nlm.nih.gov/
我正在开发一个系统,它加载一个巨大的 CSV 文件(超过 100 万行)并保存到数据库中。每行也有超过一千个字段。 CSV 文件被视为一个批处理,每一行都被视为其子对象。在添加对象的过程中,每个对象都
借助node-google模块 我编写了一个简单的 Node 模块来为我的网络应用程序启用“文本网络搜索”功能,并在我的一个 View 中显示结果。 由于在来自同一 IP 的少量查询后 Google
我有相当大的 4D 阵列 [20x20x40x15000],我使用 h5py 将其作为 HDF5 文件保存到磁盘.现在的问题是我想计算整个数组的平均值,即使用: numpy.average(HDF5_
我在遗留代码库中连接巨大的 CString 时遇到问题。 CStrings 可以包含 base64 编码的文件,因此可能很大。在某些时候,这些 CString 会像这样连接起来: result +=
我正在尝试让我的服务器提供来自另一台服务器的巨大文件。但是,为了保护我的凭据免受该远程服务器的攻击,我不能简单地将请求者重定向到文件 url;另一方面,虽然使用 StreamingHttpRespon
感谢对此的任何见解,我有 2 个问题: 1) 弄清楚为什么我的本地数据库 oplog 庞大且不断增长 2) 安全删除(或重置)我的 local.oplog 以释放 18 GB 的浪费空间 场景:我一直
我的预期任务:获取大量数据(1 GB 及更多大小)json 字符串,操作(进行一些格式化、解析 json、重组 json 数据)并写入新格式化的 json 字符串作为响应。处理这种情况的更好方法是什么
我做了一个小的 Angular 4 应用程序,但我不知道如何应用 tree shaking 和 aot 编译。我运行的命令如下: ng build --prod --aot 但我得到的结果仍然很大,供
我是一名优秀的程序员,十分优秀!