0
I我努力學習Spring MVC和時嘗試了從互聯網上一個樣品,我收到以下錯誤:<%@ taglib uri =「www.springframework.org/tags/form」prefix =「form」%><form:errors path =「student1。*」/>導致「Unable to compile JSP page」error
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>
我控制器類包含S中的下面的代碼:
@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;
}
之前在JSP頁面中添加的一切在控制BindingResult
和<form:errors>
工作正常。 當你們看,這可能是代碼中的一個小問題,但我一直試圖找出最近3-4天的問題。 請建議。
哇!非常感謝。我花了很多時間在這個http: - / –