为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕妹3146593 2021-09-15 14:43:47
我是 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>
查看完整描述

3 回答

?
慕标5832272

TA贡献1966条经验 获得超4个赞

使用此更改您的 servlet 映射并尝试;


<servlet-mapping>

    <servlet-name>appServlet</servlet-name>

    <url-pattern>/*</url-pattern>

</servlet-mapping>

在你的web.xml,你url-pattern的只是/ 。更改/*为向任何网址发送请求。


查看完整回答
反对 回复 2021-09-15
?
梦里花落0921

TA贡献1772条经验 获得超6个赞

试试下面:


<servlet-mapping>

    <servlet-name>appServlet</servlet-name>

    <url-pattern>/app/*</url-pattern>

</servlet-mapping>


查看完整回答
反对 回复 2021-09-15
?
翻阅古今

TA贡献1780条经验 获得超5个赞

感谢您的回答,显然一个简单的清理和构建解决了我的问题。


查看完整回答
反对 回复 2021-09-15
  • 3 回答
  • 0 关注
  • 244 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信