我的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>erp</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>ConnectorServlet</servlet-name>
<servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>XMLConfig</param-name>
<param-value>/WEB-INF/ckeditor.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ConnectorServlet</servlet-name>
<url-pattern>
/ckfinder/core/connector/java/connector.java
</url-pattern>
</servlet-mapping>
<filter>
<filter-name>FileUploadFilter</filter-name>
<filter-class>com.ckfinder.connector.FileUploadFilter</filter-class>
<init-param>
<param-name>sessionCookieName</param-name>
<param-value>JSESSIONID</param-value>
</init-param>
<init-param>
<param-name>sessionParameterName</param-name>
<param-value>jsessionid</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>FileUploadFilter</filter-name>
<url-pattern>
/ckfinder/core/connector/java/connector.java
</url-pattern>
</filter-mapping>
<!-- ckfinder文件上传配置 end -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/newmainform</welcome-file>
</welcome-file-list>
</web-app>
我的spring-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:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
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.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- 把标记了@Controller注解的类转换为bean -->
<context:component-scan base-package="com.mvc.controller" />
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
p:defaultEncoding="utf-8" />
<!-- @ResponseBody json -->
<!-- @ResponseBody注解支持-开始 -->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json; charset=UTF-8</value>
<value>application/x-www-form-urlencoded; charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- @ResponseBody注解支持-结束 -->
<!-- 配置扫描的包 -->
<context:component-scan base-package="com.mvc.controller"></context:component-scan>
<mvc:default-servlet-handler/>
<!-- <mvc:resources location="/css/" mapping="/css/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/script/" mapping="/script/**"/>
<mvc:resources location="/kuangjia/" mapping="/kuangjia/**"/>
<mvc:resources location="/orgchart/" mapping="/orgchart/**"/>
<mvc:resources location="/ckeditor/" mapping="/ckeditor/**"/>
<mvc:resources location="/ckfinder/" mapping="/ckfinder/**"/> -->
</beans>
小弟是刚接触jsp不久,不甚明白,请大神求解。
我访问http://localhost:8099/NewERP/ 就报404
访问http://localhost:8099/NewERP/newmainform 就正常跳转,搞了我很久了,请支招啊
10 个解决方案
#1
刚开始
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern> *.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/newmainform</welcome-file>
</welcome-file-list>
这样配的就完全没问题,改成了 / 欢迎页就不起作用了。。。。泪奔啊
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern> *.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/newmainform</welcome-file>
</welcome-file-list>
这样配的就完全没问题,改成了 / 欢迎页就不起作用了。。。。泪奔啊
#2
csdn 看来真的没落了啊
#3
你不会用spring mvc,跟csdn有什么关系?
#4
之前发个帖,十几分钟就有人回答,现在发个帖 几天都没人回复。。。
送算有个人冒出来了,还以为csdn没人用了呢
#5
也就水区有点人气,还不如去水区 问问
#6
水区不谈技术
#7
搞定了。。。尼玛,还是得靠自己
#8
怎么解决的啊????
#9
楼主楼主楼主
#10
<welcome-file-list>
<welcome-file> /Newmainform.jsp</welcome-file>
</welcome-file-list>
这里要区分大小写,而且要加上后缀啊,希望可以帮到你
<welcome-file> /Newmainform.jsp</welcome-file>
</welcome-file-list>
这里要区分大小写,而且要加上后缀啊,希望可以帮到你
楼主楼主楼主
#1
刚开始
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern> *.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/newmainform</welcome-file>
</welcome-file-list>
这样配的就完全没问题,改成了 / 欢迎页就不起作用了。。。。泪奔啊
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern> *.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/newmainform</welcome-file>
</welcome-file-list>
这样配的就完全没问题,改成了 / 欢迎页就不起作用了。。。。泪奔啊
#2
csdn 看来真的没落了啊
#3
你不会用spring mvc,跟csdn有什么关系?
#4
你不会用spring mvc,跟csdn有什么关系?
之前发个帖,十几分钟就有人回答,现在发个帖 几天都没人回复。。。
送算有个人冒出来了,还以为csdn没人用了呢
#5
你不会用spring mvc,跟csdn有什么关系?
也就水区有点人气,还不如去水区 问问
#6
你不会用spring mvc,跟csdn有什么关系?
也就水区有点人气,还不如去水区 问问
水区不谈技术
#7
搞定了。。。尼玛,还是得靠自己
#8
怎么解决的啊????
#9
楼主楼主楼主
#10
<welcome-file-list>
<welcome-file> /Newmainform.jsp</welcome-file>
</welcome-file-list>
这里要区分大小写,而且要加上后缀啊,希望可以帮到你
<welcome-file> /Newmainform.jsp</welcome-file>
</welcome-file-list>
这里要区分大小写,而且要加上后缀啊,希望可以帮到你
楼主楼主楼主