【问题标题】:HTTP Status 404 Apache Tomcat 7HTTP 状态 404 Apache Tomcat 7
【发布时间】:2016-07-15 14:33:07
【问题描述】:

我正在学习 Spring。我创建了一个 spring mvc 项目。如果我在 root-context.xml 中写下这些行:

<context:component-scan base-package="com.jaive.test.dao" />
<context:component-scan base-package="com.jaive.test.service" />

<import resource="data.xml" />

然后我得到 HTTP 状态 404。如果没有,一切正常。我想知道这些台词以及为什么会这样。我使用 Apache Tomcat 7。

data.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang              http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}" 
p:url="${jdbc.databaseurl}"
p:username="${jdbc.username}" 
p:password="${jdbc.password}" />

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
    <value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
    <value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
    <props>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.dialect">${jdbc.dialect}</prop>
        <prop key="hibernate.connection.charSet">UTF-8</prop>
    </props>
</property>
</bean>

【问题讨论】:

  • 404 的原因有很多,所以请发布您的堆栈跟踪,以便我们可以更轻松地减少问题

标签: spring spring-mvc http-status-code-404


【解决方案1】:

你配置控制器了吗,因为404总是碰巧找不到控制器,我注意到你只是没有配置你的控制器。

【讨论】:

  • 这并不总是正确的,有时tomcat配置不好会报这个错误。
猜你喜欢
  • 1970-01-01
  • 2014-05-12
  • 1970-01-01
  • 1970-01-01
  • 2014-09-11
  • 2018-05-06
  • 2017-03-28
  • 2021-06-19
  • 2017-01-04
相关资源
最近更新 更多