猿问

在调度程序 servlet 中找不到映射错误

我是 Spring MVC 的初学者,在尝试创建Spring MVC应用程序时出现以下错误:


no mapping found for http request with uri [/SpringMVCHibernateCRUD] in dispatcherservlet 'appServlet'

以下是文件:


网页.xml


<context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>/WEB-INF/spring/root-context.xml</param-value>

</context-param>



<!-- Processes application requests -->

<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/spring/appServlet/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>

servlet-context.xml


      <context:component-scan base-package="com.jwt" />


<!-- Getting Database properties -->

<context:property-placeholder location="classpath:application.properties" />


<mvc:annotation-driven />


<!-- Specifying the Resource location to load JS, CSS, Images etc -->

<mvc:resources mapping="/resources/**" location="/resources/" />


<!-- View Resolver -->

<bean

    class="org.springframework.web.servlet.view.InternalResourceViewResolver">

    <property name="prefix" value="/WEB-INF/pages/" />

    <property name="suffix" value=".jsp" />

</bean>


<!-- Transaction -->

<bean id="transactionManager"


 class="org.springframework.orm.hibernate4.HibernateTransactionManager">

    <property name="sessionFactory" ref="sessionFactory" />

</bean>


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

 </beans>


慕妹3146593
浏览 245回答 3
3回答

慕标5832272

使用此更改您的 servlet 映射并尝试;<servlet-mapping>&nbsp; &nbsp; <servlet-name>appServlet</servlet-name>&nbsp; &nbsp; <url-pattern>/*</url-pattern></servlet-mapping>在你的web.xml,你url-pattern的只是/ 。更改/*为向任何网址发送请求。

梦里花落0921

试试下面:<servlet-mapping>&nbsp; &nbsp; <servlet-name>appServlet</servlet-name>&nbsp; &nbsp; <url-pattern>/app/*</url-pattern></servlet-mapping>

翻阅古今

感谢您的回答,显然一个简单的清理和构建解决了我的问题。
随时随地看视频慕课网APP

相关分类

Java
我要回答