I'm using spring mvc 2.5.6, bootstrap3.3.2, the jsp file is:
<%@ taglib prefix="form" uri="http://ift.tt/IED0jK" %>
<%@ taglib prefix="springForm" uri="http://ift.tt/IED0jK" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<%--<link rel="icon" href="../../favicon.ico">--%>
<title>Device check</title>
<!-- Bootstrap core CSS -->
<link href="${pageContext.request.contextPath}/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="${pageContext.request.contextPath}/resources/bootstrap/css/device.css" rel="stylesheet">
<style>
.error {
color: #ee0d25;
}
</style>
</head>
<body>
<form class="form-device" method="POST" command="queryForm">
<h2 class="form-device-heading">Please fill the form</h2>
<label for="deviceId" class="sr-only">deviceId</label>
<input type="text" name="deviceId" id="deviceId" class="form-control" placeholder="deviceId">
<td><form:errors path="deviceId" cssClass="error" /></td>
<label for="startTime" class="sr-only">startTime</label>
<input type="text" name="startTime" id="startTime" class="form-control" placeholder="startTime">
<td><form:errors path="startTime" cssClass="error" /></td>
<label for="endTime" class="sr-only">endTime</label>
<input type="text" name="endTime" id="endTime" class="form-control" placeholder="endTime">
<td><form:errors path="endTime" cssClass="error" /></td>
<label for="environment" class="sr-only">environmnet</label>
<input type="text" name="environment" id="environment" class="form-control"
placeholder="daily or online">
<td><form:errors path="environment" cssClass="error" /></td>
<div class="checkbox">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
</form>
</body>
</html>
four input box here and validate them with spring's validator. but when I visit localhost:8080/form.htm, the source code of web page looks like:
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Device check</title>
<!-- Bootstrap core CSS -->
<link href="/wsf-ops/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/wsf-ops/resources/bootstrap/css/device.css" rel="stylesheet">
<style>
.error {
color: #ee0d25;
}
</style>
</head>
<body>
<form class="form-device" method="POST" command="queryForm">
<h2 class="form-device-heading">Please fill the form</h2>
<label for="deviceId" class="sr-only">deviceId</label>
<input type="text" name="deviceId" id="deviceId" class="form-control" placeholder="deviceId">
<td></td>
<label for="startTime" class="sr-only">startTime</label>
<input type="text" name="startTime" id="startTime" class="form-control" placeholder="startTime">
<td></td>
<label for="endTime" class="sr-only">endTime</label>
<input type="text" name="endTime" id="endTime" class="form-control" placeholder="endTime">
<td></td>
<label for="environment" class="sr-only">environment</label>
<input type="text" name="environment" id="environment" class="form-control"
placeholder="daily or online">
<td></td>
<div class="checkbox">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
</form>
</body>
</html>
the <form:error>
label can't be found in the page source code, so error information will not show up when input fails the validation. why is that? the device.css is copied from bootstrap sample.
Aucun commentaire:
Enregistrer un commentaire