forms - <%@ taglib uri =“www.springframework.org/tags/form”前缀=“form”%> <form :errors path =“student1.*” /> causing “Unable to compile JSP page” error

标签 forms jsp spring-mvc error-handling taglib

我正在尝试学习Spring MVC,当尝试从Internet上获取样本时,出现以下错误:

HTTP Status 500 - Unable to compile class for JSP

type Exception report

message Unable to compile class for JSP

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
    org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

java.lang.NullPointerException
    org.apache.tomcat.util.descriptor.tld.TldResourcePath.hashCode(TldResourcePath.java:164)
    java.util.HashMap.hash(HashMap.java:338)
    java.util.HashMap.get(HashMap.java:556)

这是我的JSP页面:
<%@taglib uri="www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<title>Admission Form</title>
</head>
<body>

<h1>${header_msg}</h1>
<h3>Admission Form for Engineering Courses</h3>

<form:errors path="student1.*" />
<form action="/Admissions/submitAdmissionForm.html" method="post">
    <table>
    <tr><td> Student's Name :   </td><td>   <input type="text" name="studentName" />    </td></tr>
    <tr><td> Student's Hobby :  </td><td>   <input type="text" name="studentHobby" />   </td></tr>
    <tr><td> Date of Birth :    </td><td>   <input type="text" name="studentDOB" />     </td></tr>
    <tr><td> Mobile No :        </td><td>   <input type="text" name="studentMobile" />  </td></tr>

    <tr><td> Skill set :        </td><td>   <select name="studentSkills" multiple>
                                            <option value="Core Java">Core Java</option>
                                            <option value="Spring Core">Spring Core</option>
                                            <option value="Spring MVC">Spring MVC</option>
                                            </select> </td></tr>
    </table>

    <table>
    <tr><td> Address :  </td></tr>
    <tr><td> Country:   <input type="text" name="studentAddress.country" />     </td>
        <td> City:      <input type="text" name="studentAddress.city" />        </td>
        <td> Street:    <input type="text" name="studentAddress.street" />      </td>
        <td> Pin code:  <input type="text" name="studentAddress.pincode" />     </td></tr>

    <tr><td> </td><td>  <input type="submit" value="Submit this form" />        </td></tr>
    </table>
</form>

</body>
</html>

我的 Controller 类包含以下代码:
@ModelAttribute
public void addingCommonObjects(ModelAndView model) {

    model.addObject("header_msg", "College of Engineering, Adoor");
}

@RequestMapping(value="/submitAdmissionForm.html", method=RequestMethod.POST)
public ModelAndView submitAdmissionForm(@ModelAttribute("student1") Student student, BindingResult result) {

    if(result.hasErrors()) {
        ModelAndView model = new ModelAndView("AdmissionForm");
        return model;
    }
    ModelAndView model = new ModelAndView("AdmissionFormSuccess");
    return model;
}

在 Controller 中添加BindingResult以及在JSP页面中添加<form:errors>之前,一切工作正常。
当你们看的时候,这可能是代码中的一个小问题,但是我一直在尝试找出最近3-4天的问题。
请提出建议。

最佳答案

<%@taglib uri="www.springframework.org/tags/form" prefix="form" %>

uri在以上行中不正确。 uri中缺少 http 。尝试下面
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>

关于forms - <%@ taglib uri =“www.springframework.org/tags/form”前缀=“form”%> <form :errors path =“student1.*” /> causing “Unable to compile JSP page” error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34036324/

相关文章:

jquery - jquery如何修改formData

forms - 父类中的 Symfony 4 setter 注入(inject)

java - 如何将 spring 表单输入占位符属性值引用到消息源属性?

java - 查找 Java/JSP 代码中潜在的 SQL 注入(inject)问题

spring-mvc - 在 Liferay 选项卡的选项卡标题中使用空格

php - Python : extract . 将数据提交到具有机械化的表单后的 csv 结果

php - 如何使用 symfony2 "manually"处理文件上传?

mysql - 使用 JSP 显示来自 MYSQL 的登录用户特定数据

java - Spring MVC 测试、JNDI

java - 如何为每个团队成员在unix中设置java开发环境