我嘗試解決了這個問題,我在計算器中遇到但沒有工作對我來說org.springframework.web.servlet.PageNotFound:1108
所有的解決方案,這是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
這是我的servlet上下文的XML:
<!-- Enable @Controller annotation support -->
<mvc:annotation-driven />
<!-- Esta etiqueta es para mapear carpetas dentro de src/main/webapp
de lo contrario el servidor no las reconoceria
-->
<!-- <mvc:resources mapping="/css/**" location="/css/" /> -->
<!-- Map simple view name such as "test" into /WEB-INF/PAGE/test.jsp -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/page/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views" />
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"></bean>
<!-- Scan classpath for annotations (eg: @Service, @Repository etc) -->
<context:component-scan base-package="com.ieea.dao" />
<context:component-scan base-package="com.ieea.controller" />
<!-- Contenido agregador -->
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
</bean>
<!-- Contenido agregador -->
<!-- JDBC Data Source. It is assumed you have MySQL running on localhost
port 3306 with username root and blank password. Change below if it's not
the case -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/******" />
<property name="username" value="*****" />
<property name="password" value="*****" />
<property name="validationQuery" value="SELECT 1" />
</bean>
<!-- Hibernate Session Factory -->
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="packagesToScan">
<array>
<value>com.ieea.domain</value>
</array>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
<!-- <value> hibernate.dialect=org.hibernate.dialect.MySQLDialect </value> -->
</property>
</bean>
<!-- Hibernate Transaction Manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory" />
</bean>
<!-- Activates annotation based transaction management -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
控制器:
@Controller
public class UsuarioController {
@Autowired UsuarioDAOImpl usuarioDAO;
@RequestMapping(value = "lista", method = RequestMethod.GET)
public String testReporte(Model model) {
try {
System.out.println("Entre");
List<Usuario> lista = usuarioDAO.encontrarTodosUsuarios();
model.addAttribute("lista", lista);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return "index";
}
}
我認爲這個問題出現在web.xml或servlet-context.xml中 我不知道我的應用程序發生了什麼,春天的其他應用程序永遠不會導致這個問題。
org.springframework.web.servlet.PageNotFound:1108 - 否的DispatcherServlet找到HTTP請求與URI [/ usuariosTest /]與名稱映射 'appServlet'
您似乎沒有'/ usuariosTest /'處理程序。 – 2014-08-27 18:55:21
「我嘗試用我在stackoverflow中遇到的所有解決方案來解決此問題」。所以你說。但是,由於您不告訴我們您嘗試過哪些解決方案,爲什麼他們不工作,我們沒有理由相信您。 – Raedwald 2014-08-28 06:39:10