这个是目录
------------package javabean;public class uesr {
    private String name;
    private String password;
    private String sex;
    private String city;
    private String note;
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
    
    
}
------------package test;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javabean.*;
@Controller
public class controller1 {
@RequestMapping(method=RequestMethod.POST, value="/app/reg")
public String reg(@RequestParam uesr u,ModelMap model){
    model.addAttribute("say","i want say hello spring mvc");
model.addAttribute("uesr",u);
return "prl"; 
   }



}------
配置/tianli0702/WebRoot/WEB-INF/web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>test</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param> <!-- Character Encoding filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!--Spring ApplicationContext 载入 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- 扩展spring bean的作用域有request,session,global session等-->  
    <listener>  
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>  
    </listener>  
    
    <!-- Spring 刷新Introspector防止内存泄露 -->  
    <listener>  
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>  
    </listener>
    
<!-- 这上面的东西暂时不用管 -->
 <servlet>
 <servlet-name>tianli</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 </servlet>
 
 <servlet-mapping>
 <servlet-name>dispatcherServlet</servlet-name>
 <url-pattern>/app/*</url-pattern>
 </servlet-mapping>
 
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>
-配置/tianli0702/WebRoot/WEB-INF/tianli-servlet.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd" >
     <context:component-scan base-package="test"/>
     <context:component-scan base-package="javabean"/>
  <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">  
        <property name="order" value="1" />  
    </bean>  
    <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">  
        <property name="order" value="2" />  
    </bean>
    
  <bean id="freeerConfig" class="org.springframework.web.servlet.view.freeer.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="/WEB-INF/freeer/"/>
   </bean>   <!--也可以把ResourceBundle或XML文件配置到视图解析器中。如果你需要根据Locale来解析不同的视图,就需要使用resource bundle解析器。-->
   <bean id="viewResolver" class="org.springframework.web.servlet.view.freeer.FreeMarkerViewResolver">
     <property name="cache" value="true"/>
     <property name="prefix" value=""/>
     <property name="suffix" value=".html"/>
   </bean>     
</beans>----------配置/tianli0702/WebRoot/WEB-INF/applicationContext.xml<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <context:annotation-config /></beans>----
tomcat启动的时候出错2010-7-2 15:44:52 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\tianli\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2010-7-2 15:44:52 org.apache.tomcat.util.digester.Digester endElement
严重: End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
hod)
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:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
2010-7-2 15:44:52 org.apache.catalina.startup.ContextConfig applicationWebConfig
严重: Occurred at line 51 column 20
2010-7-2 15:44:52 org.apache.catalina.startup.ContextConfig start
严重: Marking this application unavailable due to previous error(s)
2010-7-2 15:44:52 org.apache.catalina.core.StandardContext start
严重: Error getConfigured
2010-7-2 15:44:52 org.apache.catalina.core.StandardContext start
严重: Context [/tianli] startup failed due to previous errors

解决方案 »

  1.   

    信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\tianli\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    2010-7-2 15:44:52 org.apache.tomcat.util.digester.Digester endElement
    检查你的jar包
      

  2.   


    2010-7-2 15:44:52 org.apache.catalina.loader.WebappClassLoader validateJarFile
    信息: validateJarFile(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\tianli\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
    2010-7-2 15:44:52 org.apache.tomcat.util.digester.Digester endElement
    严重: End event threw exception
    java.lang.reflect.InvocationTargetExceptionjar包冲突
    请删掉c3p0.jar和多余的jar包
    如 common-logging、log4j 有2个的都删掉一个