期望JSP异常引号符号

时间:2015-02-03 12:25:22

标签: java spring twitter-bootstrap jsp

我是Spring MVC,JSP和bootstrap的新手。我试图在表单中创建一个符号并从中读取值。为此,我写的login.jsp文件是;

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Bootstrap Form With Spring Mvc Example</title>
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css"
    rel="stylesheet">
<link href="https://code.jquery.com/jquery-2.1.3.js" rel="stylesheet">
</head>
<body>
    <jsp:include page="header.jsp"></jsp:include>

    <div class="container">
        <form:form class="form-signin" method="POST" commandName="user">
            <h2 class="form-signin-heading">
                <spring:message code="main.signin" />
            </h2>
            <label for="email" class="sr-only">
                <spring:message code="main.email" />
            </label> 
            <form:input type="email" path="email" id="email" class="form-control" placeholder=<spring:message code="main.email"/> required autofocus/>

            <label for="password" class="sr-only">
                <spring:message code="main.password" />
            </label> 
            <form:input type="password" path="password" id="password" class="form-control" placeholder=<spring:message code="main.password"/> required/>

            <div class="checkbox">
                <label> <input type="checkbox" id="rememberme">
                    <spring:message code="main.rememberMe" />
                </label>
            </div>
            <input class="btn btn-lg btn-primary btn-block" type="submit" id="submit" value=<spring:message code="main.signinBtn" /> >
        </form:form>
    </div>

    <jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

但是我得到了

SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/SpringMVC] threw exception [/WEB-INF/pages/login.jsp (line: 26, column: 86) quote symbol expected] with root cause
org.apache.jasper.JasperException: /WEB-INF/pages/login.jsp (line: 26, column: 86) quote symbol expected

异常。我得到这个例外的那一行是

<form:input type="email" path="email" id="email" class="form-control" placeholder=<spring:message code="main.email"/> required autofocus/>

我对这个问题一无所知。你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

您无法以<spring:message>的方式使用<form:input>。请查看此问题以获得解决方案:how-to-use-springmessage-inside-an-attribute-of-forminput