HTTP Status 404 - servlet文件无法访问

CAT_SEVEN 2017-04-22 05:37:17
利用SpringMVC做一个简单 的文件上传功能,web.xml配置文件如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"
>
<display-name>Apr20_SpringMVC</display-name>

<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 指定spring的指定文件 -->
<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>*.from</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

url映射路径为*.from 可是无法跳转?
spring-mvc.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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jpa="http://www.springframework.org/schema/jpa" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/context/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/jpa
http://www.springframework.org/schema/jpa/spring-jpa-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="com.controller"/>
<mvc:annotation-driven />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/">
</property>
<property name="suffix" value=".jsp">
</property>
</bean>

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置上传文件大小 -->
<property name="maxUploadSize" value="51200"></property>
<property name="resolveLazily" value="true"></property>

</bean>
</beans>

如何解决?
...全文
270 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
MonkeyHou0529 2017-04-24
  • 打赏
  • 举报
回复
引用 2 楼 CAT_SEVEN的回复:
[quote=引用 1 楼 qq_38039130 的回复:] 你这问题问的,表示看不懂,找到重点在问吧,起码你把报错信息发来,访问路径发来吧
访问路径为:
http://localhost:8080/Apr20_SpringMVC/toUpload.from
报错信息是http404 message处为空白?[/quote] 1,不知道你的controller怎么配的路径;2,你引入jdbc那个配置有一个没改到,把context改成jdbc
MonkeyHou0529 2017-04-23
  • 打赏
  • 举报
回复
你这问题问的,表示看不懂,找到重点在问吧,起码你把报错信息发来,访问路径发来吧
CAT_SEVEN 2017-04-23
  • 打赏
  • 举报
回复
引用 1 楼 qq_38039130 的回复:
你这问题问的,表示看不懂,找到重点在问吧,起码你把报错信息发来,访问路径发来吧
访问路径为:
http://localhost:8080/Apr20_SpringMVC/toUpload.from
报错信息是http404 message处为空白?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧