2013-03-27 105 views
0

我想在eclipse中運行一個簡單的jsp程序,但是當我運行程序時,我得到以下errors.I工作與春天現在,我已經添加了所有的罐子正確地在正確的path.The JSP程序如下春天扔加載異常(java.lang.NoSuchMethodError :)

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Insert title here</title> 
</head> 
    <body> 
    <h1>WELCOME TO EMPLOYEE ACCESS SITE.PLEASE ENTER THE FOLLOWING INFORMATION</h1> 
    <form:form method="POST" action="/Spring/mvc1/addStudent"> 
    <table> 
    <tr> 
     <td><form:label path="name">Name</form:label></td> 
     <td><form:input path="name" /></td> 
    </tr> 

    <tr> 
     <td><form:label path="id">id</form:label></td> 
     <td><form:input path="id" /></td> 
    </tr> 
    <tr> 
     <td colspan="2"> 
     <input type="submit" value="Submit"/> 
     </td> 
    </tr> 
    </table> 
</form:form> 
    </body> 
</html> 

,當我運行這個程序上面我得到以下一組錯誤的

SEVERE: Servlet /Spring threw load() exception 
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V 
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:454) 
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483) 
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358) 
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325) 
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) 
at javax.servlet.GenericServlet.init(GenericServlet.java:212) 
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) 
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) 
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058) 
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364) 
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) 
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) 
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) 
at org.apache.catalina.core.StandardService.start(StandardService.java:516) 
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) 
at org.apache.catalina.startup.Catalina.start(Catalina.java:578) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) 
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 
Mar 27, 2013 11:02:15 AM org.apache.coyote.http11.Http11Protocol start 
INFO: Starting Coyote HTTP/1.1 on http-8080 
Mar 27, 2013 11:02:15 AM org.apache.jk.common.ChannelSocket init 
INFO: JK: ajp13 listening on /0.0.0.0:8009 
Mar 27, 2013 11:02:15 AM org.apache.jk.server.JkMain start 
INFO: Jk running ID=0 time=0/109 config=null 
Mar 27, 2013 11:02:15 AM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 2471 ms 
Mar 27, 2013 11:02:23 AM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet jsp threw exception 
java.lang.IllegalStateException: No WebApplicationContext found: no 
ContextLoaderListener registered? 
at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84) 
at org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:81) 
at org.springframework.web.servlet.support.RequestContext.initContext(RequestContext.java:219) 
at org.springframework.web.servlet.support.JspAwareRequestContext.initContext(JspAwareRequestContext.java:74) 
at org.springframework.web.servlet.support.JspAwareRequestContext.<init>(JspAwareRequestContext.java:48) 
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:76) 
at org.apache.jsp.mvc11.student_jsp._jspx_meth_form_005fform_005f0(student_jsp.java:104) 
at org.apache.jsp.mvc11.student_jsp._jspService(student_jsp.java:73) 
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) 
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) 
at java.lang.Thread.run(Thread.java:619) 

我還沒有鏈接的JSP頁面Spring類還我只是想看到前端顯示器。我不知道問題出在哪裏......

+0

你嘗試我在下面的答案解釋呢? – 2013-03-27 16:31:37

回答

0

您的JSP頁面應該由Spring Controller返回。如果您在JSP中沒有使用Spring表單標籤,那麼它會起作用,但是您在JSP中的表單具有需要名稱和ID路徑的標籤。他們應該來自一個豆子。所以你需要將這個bean/POJO和JSP一起傳遞。在Model對象中添加bean。

代碼將是這樣的:假設 網頁的網址是:http://localhost:8484/yourappcontext/student

@Controller 
public class StudentController { 

    @RequestMapping(value="/student", method = RequestMethod.GET) 
    public String showAddStudentPage(Model model) { 

     // instantiate empty student pojo containing name & id needed by JSP 
     Student student = new Student(); 

     // add student pojo in model being sent with JSP 
     model.addSttribute("student", student); 

     return "addStudent"; // this would be your JSP name. 
    } 
}