spring_mvc中的问题

在看到第三讲的时候碰到java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config错误!
代码如下:
StartController :
复制代码
  1. package com.nilpower.test;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.Controller;




    public class StartController implements Controller {

        public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
            System.out.println("controller is working!");
            return new ModelAndView("start"); //返回一个逻辑视图
        }

    }


test-servlet.xml
复制代码
  1. <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        
        <!-- 定义映射处理器 -->
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <!-- 定义请求的名字为start.test,然后去调用startController处理器 -->
                    <prop key="start.test">startController</prop>
                </props>
            </property>
        </bean>
        
        <!-- 控制器 -->
        <bean id="startController" class="com.nilpower.test.StartController"></bean>
        
        <!-- 视图解析器 -->
        <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
            <property name="prefix" value="/WEB-INF/jsp/" />
            <property name="suffix" value=".jsp" />
        </bean>
    </beans>


通过http://localhost:8080/SpringMVCTest01/start.test访问时报错.. 具体是因为添加了viewClass.以及org.springframework.web.servlet.view.JstlView




解决办法:

在WEB-INF的lib下面添加:jstl.jar 和 standard.jar就可以了

下载地址:http://www.apache.org/dist/jakarta/taglibs/standard/jakarta-taglibs-standard-current.zip

你可能感兴趣的:(spring_mvc中的问题)