Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带springmvc的maven_Spring_Model View Controller_Maven - Fatal编程技术网

带springmvc的maven

带springmvc的maven,spring,model-view-controller,maven,Spring,Model View Controller,Maven,有谁在maven和spring中有web项目吗? 我不知道为什么我不能让我的项目工作,因此我需要看到一个工作的项目来理解它。 使用SpringMVC在maven中进行简单登录/注销的项目 坦克 当我在服务器上运行项目时,我得到了一个HTTP404,我不知道会出什么问题。 我的xml文件的som可能有问题: web.xml org.hibernate.ejb.HibernatePersistence spring-servlet.xml <?xml version="1.0" enc

有谁在maven和spring中有web项目吗? 我不知道为什么我不能让我的项目工作,因此我需要看到一个工作的项目来理解它。 使用SpringMVC在maven中进行简单登录/注销的项目

坦克

当我在服务器上运行项目时,我得到了一个HTTP404,我不知道会出什么问题。 我的xml文件的som可能有问题:

web.xml


org.hibernate.ejb.HibernatePersistence

spring-servlet.xml

<?xml version="1.0" encoding="windows-1252"?>
   <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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
   http://www.springframework.org/schema/aop
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<!-- Use @Component annotations for bean definitions -->
<context:component-scan base-package="se.guard.domain" />
<context:component-scan base-package="se.guard.repository" />
<context:component-scan base-package="se.guard.service" />
<context:component-scan base-package="se.guard.controller" />

<!-- Use @Controller annotations for MVC controller definitions -->
<mvc:annotation-driven />

<!-- Add JPA support -->
<bean id="emf"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="loadTimeWeaver">
        <bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    </property>
</bean>
<!-- Add Transaction support -->
<bean id="myTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="emf" />
</bean>
<!-- Use @Transaction annotations for managing transactions -->
<tx:annotation-driven transaction-manager="myTxManager" />
<!-- View resolver -->
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/" />
    <property name="suffix" value=".jsp" />
</bean>
</beans>

使用Spring或Maven使用Spring MVC创建工作应用程序

您可以使用它生成Spring推荐的项目结构,该项目结构使用Maven并自动配置了正确的依赖项。
您可以使用它与Spring安全性集成,以便登录和注销。

我在web.xml中没有看到Spring配置。不要忘记添加弹簧配置。例如:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>
...
<servlet>
    <servlet-name>YourServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/spring/webmvc-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>YourServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
...

上下文配置位置
classpath*:META-INF/spring/applicationContext*.xml
...
YourServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
WEB-INF/spring/webmvc-config.xml
1.
YourServlet
/
...
顺便说一句,在(Springsource工具套件)中有一个有趣的选项:文件>新建>项目>Springsource工具套件>Spring模板项目。然后选择SpringMVC项目,您将得到一个使用Maven和SpringMVC的HelloWorld项目


此外,正如萨默斯所指出的,SpringRoo对于Spring应用程序引导来说是很酷的

您应该发布遇到的任何错误,以便我们能够更好地帮助您。这是一个非常模糊的问题。哪个版本的spring?另外,登录/注销意味着您需要spring安全性。我认为它可以满足您的所有需要:)祝您好运!还有spring-service.xml
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>
...
<servlet>
    <servlet-name>YourServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/spring/webmvc-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>YourServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
...