amenlv 2010-01-07 19:05
浏览 329
已采纳

spring mvc 无法加载jsp页面

一个spring mvc的实验,里面的页面html的就好用,换成jsp就500 ,求解!!!

项目情况:

见附件的图片。

 

配置文件:

1.applicationContext.xml

   <bean id="userDao" class="cn.edgedu.dao.impl.UserDaoMysqlImpl"></bean>
    <bean id="userService" class="cn.edgedu.service.impl.UserServiceImpl">
        <property name="userDao" ref="userDao"></property>
    </bean>

2.dispatch-servlet.xml

   <bean name="/login.do" class="cn.edgedu.web.LoginHandler">
        <property name="userService" ref="userService"></property>
        <property name="forwardInit">
            <value>/html/login.jsp</value>
        </property>
        <property name="forwardSucc" value="/html/main.jsp"></property>
        <property name="forwardFail" value="/html/login.jsp"></property>
    </bean>

3.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>sprmvc</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatch</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatch</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

代码文件:

1.index.jsp 页面

<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
    welcome!
    <a href="login.do?event=INIT">login</a>
</body>
</html>

报错信息:

当运行项目访问主页时,有如下报错(html的就好用,jsp就报错)

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

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

exception 

org.apache.jasper.JasperException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.NullPointerException
    org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
    org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18

 

郁闷好久了~~各种google也搞不定,求解答。。。谢谢!!


问题补充:
To :sunlightcs (资深程序员)
感谢回答,但是我现在还没运行任何业务,只是显示主页(见index.html页面)就抛500 ,好像是容器无法编译jsp页面呢。。。
  • 写回答

3条回答 默认 最新

  • CaiHuajiang 2010-01-08 13:30
    关注

    springMVC中没有配置viewResolver
    参考SpringMVC指南中view和viewResolver章节

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB代码补全插值
  • ¥15 Typegoose 中如何使用 arrayFilters 筛选并更新深度嵌套的子文档数组信息
  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的