2017-04-30 1 views
-1

ich mache eine Anwendung in Spring MVC und ich möchte Bootstrap verwenden, aber ich kann den Ressourcenordner nicht verknüpfen, wenn ich versuche, meine App zu verwenden, stürzt wie verrückt, gibt es einen anderen Weg den Ressourcenordner zuordnen?SPRING MVC Wie man Ressourcen abbildet

hier ist mein Dispatcher-Servlet

<?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:p="http://www.springframework.org/schema/p" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
          http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">--> 
<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:tx="http://www.springframework.org/schema/tx" 
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/mvc    
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 

<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> 

<!-- 
Most controllers will use the ControllerClassNameHandlerMapping above, but 
for the index controller we are using ParameterizableViewController, so we must 
define an explicit mapping for it. 
--> 
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> 
    <property name="mappings"> 
     <props> 

      <prop key="index.htm">indexController</prop> 
      <prop key="home.htm">homeController</prop> 
      <prop key="cliente.htm">AdministracionController</prop> 
      <prop key="receta.htm">RecetaController</prop> 
      <prop key="ingrediente.htm">IngredienteController</prop> 
      <prop key="AñadirCliente.htm">AdministracionController</prop> 
      <prop key="AñadirUsuario.htm">InfoclienteController</prop> 
      <prop key="editarUsuario.htm">UsereditController</prop> 
      <prop key="login.htm">LoginController</prop> 
      <prop key="compañia.htm">homeController</prop> 
      <prop key="socios.htm">homeController</prop> 
      <prop key="soluciones.htm">homeController</prop> 
      <prop key="listaUsuario.htm">InfoclienteController</prop> 
      <prop key="consultaMinuta.htm">SupervisorController</prop> 
      <prop key="consultaExito.htm">SupervisorController</prop> 
      <prop key="consultaError.htm">SupervisorController</prop> 
      <prop key="minutaDia.htm">SupervisorController</prop> 
      <prop key="editarCliente.htm">ClienteController</prop> 
      <prop key="admHome.htm">Administrador2Controller</prop> 
      <prop key="encarHome.htm">EncargadoController</prop> 
      <prop key="infoCliente.htm">InfoclienteController</prop> 
      <prop key="listaCasino.htm">CasinoController</prop> 
      <prop key="AñadirCasino.htm">CasinoController</prop> 
      <prop key="editarCasino.htm">CasinoeditController</prop> 
      <prop key="AñadirIngrediente.htm">IngredienteController</prop> 
      <prop key="editarIngrediente.htm">Ingrediente2Controller</prop> 
      <prop key="AñadirReceta.htm">RecetaController</prop> 
      <prop key="editarReceta.htm">Receta2Controller</prop> 

      <prop key="Encargado/ingrediente.htm">IngredienteControllerEncargado</prop> 
      <prop key="Encargado/AñadirIngrediente.htm">IngredienteControllerEncargado</prop> 
      <prop key="Encargado/editarIngrediente.htm">Ingrediente2ControllerEncargado</prop> 
      <prop key="Encargado/receta.htm">RecetaControllerEncargado</prop> 
      <prop key="Encargado/AñadirReceta.htm">RecetaControllerEncargado</prop> 
      <prop key="Encargado/editarReceta.htm">Receta2ControllerEncargado</prop> 
     </props>    
    </property> 
</bean> 

<bean id="viewResolver" 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
     p:prefix="/WEB-INF/jsp/" 
     p:suffix=".jsp" /> 




<bean name="Receta2ControllerEncargado" class="controller.Receta2ControllerEncargado" /> 
<bean name="RecetaControllerEncargado" class="controller.RecetaControllerEncargado" /> 
<bean name="Ingrediente2ControllerEncargado" class="controller.Ingrediente2ControllerEncargado" /> 
<bean name="IngredienteControllerEncargado" class="controller.IngredienteControllerEncargado" /> 

<bean name="Receta2Controller" class="controller.Receta2Controller" /> 
<bean name="RecetaController" class="controller.RecetaController" /> 
<bean name="Ingrediente2Controller" class="controller.Ingrediente2Controller" /> 
<bean name="IngredienteController" class="controller.IngredienteController" /> 
<bean name="InfoclienteController" class="controller.InfoclienteController"/> 
<bean name="homeController" class="controller.homeController"/> 
<bean name="AdministracionController" class="controller.AdministracionController"/> 
<bean name="SupervisorController" class="controller.SupervisorController"/> 
<bean name="LoginController" class="controller.LoginController"/> 
<bean name="ClienteController" class="controller.ClienteController"/> 
<bean name="Administrador2Controller" class="controller.Administrador2Controller"/> 
<bean name="CasinoController" class="controller.CasinoController"/> 
<bean name="CasinoeditController" class="controller.CasinoeditController"/> 
<bean name="UsereditController" class="controller.UsereditController"/> 

<bean name="EncargadoController" class="controller.EncargadoController"/> 
<bean name="indexController" 
     class="org.springframework.web.servlet.mvc.ParameterizableViewController" 
     p:viewName="index" /> 



</beans> 
+0

Gibt es einen Grund, warum Sie all diese Konfiguration von Hand machen? Spring Boot mit Annotation-Konfiguration würde 100% davon unnötig machen. – chrylis

+0

Ich bin neu mit Feder mvc, ich weiß nicht, wie Spring Booth zu verwenden oder was ist in der Lage, ich kenne die Grundlagen des Frühlings mvc wie Erstellen eines CRUD und ich verwende die Standardkonfiguration, die Netbeans erstellt, wenn Sie wählen ein neues Projekt – Crhonox

+0

Schauen Sie sich die "Spring Boot Getting Started Guides" und [Spring Initializr] (https://start.spring.io) an. Sie haben viel Arbeit investiert, um den Einstieg zu erleichtern und "gewöhnliche" Projekte zu erstellen. – chrylis

Antwort

0

schließlich ich es

<mvc:default-servlet-handler/> 
<bean  class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> 

und die Änderung meiner web.xml

von

<servlet-mapping> 
    <servlet-name>dispatcher</servlet-name> 
    <url-pattern>*.htm</url-pattern> 
</servlet-mapping> 
durch das Hinzufügen dieser zu meinem Dispatcher Servlet fixiert

bis

<servlet-mapping> 
    <servlet-name>dispatcher</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 

so der Dispatcher Servlet verwalten alle die Anforderung statt nur die HTM

aber jetzt habe ich andere Frage, ist normal so viele Controller haben? Zur Zeit mache ich einen Controller pro Ansicht und Formular.