springmvc 访问不到control无法进行视图解析。

web.xml文件

 <?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
         id="WebApp_ID" version="2.5">
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
    <filter-name>CharacterEncodingFilter</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>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring-mvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.shtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

spring-mvc文件

 <?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: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/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <mvc:annotation-driven/>
    <context:component-scan
            base-package="com.nuist.controller"/>

    <!-- 视图解析器,根据视图的名称new ModelAndView(name),在配置文件查找对应的bean配置 -->
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="order" value="1"/>
        <property name="defaultViews">
            <list>
            </list>
        </property>
    </bean>
    <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath" value="/WEB-INF"/>
        <property name="configLocation" value="classpath:velocity.properties"/>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="order" value="2"/>
        <property name="suffix" value=".vm"/>
        <property name="prefix" value="/"/>
        <property name="exposeSpringMacroHelpers" value="true"/>
        <property name="requestContextAttribute" value="rc"/>
        <property name="contentType" value="text/html;charset=UTF-8"/>
        <!--<property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>-->
    </bean>
</beans>

control类

 package com.nuist.controller;

import com.nuist.pojo.ScheduleJobVo;
import com.nuist.services.ScheduleJobService;
import com.nuist.utils.common.ScheduleUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;
import java.util.List;
@Controller
public class TestController {
@RequestMapping(value = "test", method = RequestMethod.GET)
    public String test(ScheduleJobVo scheduleJobVo, ModelMap modelMap) {
        *****
                return "test";
}

说明:发布项目后文件
图片说明
velocity.properties配置文件

 #tools.view.servlet.layout.directory = /WEB-INF/templates/layout/
tools.view.servlet.layout.default.template = default.vm
default.contentType=text/html;charset=utf-8
input.encoding = UTF-8
output.encoding = UTF-8
class.resource.loader.cache=false
velocimacro.library.autoreload=true
directive.set.null.allowed = true
runtime.log.error.stacktrace = true
runtime.log.warn.stacktrace = true
runtime.log.info.stacktrace = true
runtime.log.logsystem.class = org.apache.velocity.runtime.log.SimpleLog4JLogSystem
runtime.log.logsystem.log4j.category = velocity_log

请问配置哪里出现问题导致我访问test.shtml时出现404的错误

好像是路径错了

  <property name="prefix" value="/WEB-INF/"/>

1、首先你需要修改这句改成
2、然后,你试试在spring-mvc.xml文件中的 mvc:annotation-driven/上面一行加这么一句:mvc:default-servlet-handler/
如果还不能访问,我们再找别的原因

1、首先你需要修改这句改成
2、然后,你试试在spring-mvc.xml文件中的

 <mvc:annotation-driven/>

上面一行加这么一句:

 <mvc:default-servlet-handler/>


如果还不能访问,我们再找别的原因
刚才回答的没有用代码片插入,居然没有尖括号,问题是慢慢找的,不要急

看了楼主个其他朋友的讨论,如果spring-mvc.xml在tomcat启动的时候没有加载,会不会是web.xml路径配置有问题? 你的classes下就是spring-mvc.xml吗?

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring.xml</param-value>
</context-param>

这块写的是spring.xml那么程序启动时就会去找名字叫spring的xml配置文件,但你后面配置文件叫spring-mvc.xml,所以是无法加载的

在上面的问题解决后,你的controller类上面也需要requestMapping映射路径,这样才能进入类访问到具体的方法进行操作

统一回复:以上文件配置没有问题,后来我发现tomcat在启动的时候spring-mvc没有加载,第一反应是web.xml的配置出现问题,但是多次检查无果,后来偶尔出现找不到class的情况,但是我引用了jar,并且已经完整发布不可能出现这样的问题。
到此问题已经找到,由于我用的是IDEA的开发工具,并使用maven管理,这个项目被我改了项目名称,导致图片说明Artifacts中出现了四个待部署的web项目,各个项目都引用了maven导入的包,所以只要去除之前命名项目的待部署项目即可。