SpringMVC的问题No mapping found for HTTP request with URI
做了一个屏蔽进数据库的操作:
Applicaition.xml配置:
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"> <!-- 配置数据源,记得去掉myBatis-config.xml的数据源相关配置 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/mybatis2?useUnicode=true&characterEncoding=UTF-8" />
<property name="user" value="root" />
<property name="password" value="123456" />
</bean>
<!-- 配置session工厂 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean> <!-- 配置事务管理器,管理数据源事务处理 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置事务通知 -->
<tx:advice id="advice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 默认只处理运行时异常,可加rollback-for="Exception/Throwable"等处理所有异常或包括错误 -->
<tx:method name="insert*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="update*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="delete*" propagation="REQUIRED"
rollback-for="Exception" />
<tx:method name="*" propagation="SUPPORTS" />
</tx:attributes>
</tx:advice> <!-- 配置SessionTemplate,已封装了繁琐的数据操作 -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"
scope="prototype">
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean> <!-- 配置切面织入的范围,后边要把事务边界定在service层 -->
<aop:config>
<aop:advisor advice-ref="advice"
pointcut="execution(* com.liuyang.crm.service.Imp.*.*(..))" />
</aop:config> <context:component-scan base-package="com.liuyang" />
<!--context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"
/> </context:component-scan --> </beans>
防止错误数据进入的屏蔽
<context:component-scan base-package="com.liuyang" />
<!--context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"
/> </context:component-scan -->
这里其实注销掉,也是好使的.加上了就出现文章上边的找不到url地址注入的错误.
spring-mvc.xml
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
"> <!-- 同时开启json格式的支持 -->
<mvc:annotation-driven></mvc:annotation-driven> <context:component-scan base-package="com.liuyang">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Service" />
</context:component-scan> </beans>
这里配置屏蔽就可以,这样数据库同样不进错误数据.
<context:component-scan base-package="com.liuyang">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Service" />
</context:component-scan>
@Override
public int insertDept(Dept dept) throws Exception {
int i = 0;
i = deptDao.insertDept(dept);
Integer.parseInt("aa");
return i;
}
希望对您有帮助,感谢您的观看.
SpringMVC的问题No mapping found for HTTP request with URI的更多相关文章
- (一)SpringMVC之警告: No mapping found for HTTP request with URI
这个警告往往是因为url路径不正确. 所以从三个地方下手: 1.springmvc-config.xml中的配置handle,看看是不是因为handle没有配置导致的. 2.如果是使用注解的方式的话, ...
- springmvc No mapping found for HTTP request with URI in Dispatc
springmvc No mapping found for HTTP request with URI in Dispatc 博客分类: Java Web springmvcspring MVCNo ...
- 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...
- No mapping found for HTTP request with URI [/crmcrmcrm/css/bootstrap.min.css] in DispatcherServlet with name 'springMvc'
先把错误贴上来 No mapping found for HTTP request with URI [/crmcrmcrm/css/sb-admin-2.css] in DispatcherServ ...
- Servlet3模块化应用中,@Controller没有被注入,导致出现:No mapping found for HTTP request with URI [/xxx/xxx] in DispatcherServlet with name 'springmvc'
问题描述:Servlet3模块化应用中,@Controller没有被注入,导致出现: org.springframework.web.servlet.DispatcherServlet noHandl ...
- No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'
控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...
- '/'和‘/*’差异造成的No mapping found for HTTP request with URI [/springMVC/welcome.jsp] in DispatcherServlet with name 'springmvc'
在采用springMVC框架的时候所遇到的一个小问题,其中web.xml中关于servlet的配置如下: <servlet> <servlet-name>springmvc&l ...
- SpringMvc出现No mapping found for HTTP request with URI的终极解决办法
No mapping found for HTTP request with URI 出现这个问题的原因是在web.xml中配置错了,如: <servlet> <servlet-na ...
- springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'
项目是使用spring MVC (1)在浏览器中访问,后台总报错: No mapping found for HTTP request with URI [/exam3/welcome] in Dis ...
随机推荐
- 监控服务器所有用户的操作记录(测试只记录root用户)
在linux系统的环境下,不管是root用户还是其它的用户只有登陆系统后用进入操作我们都可以通过命令history来查看历史记录,可是假如一台服务器多人登陆,一天因为某人误操作了删除了重要的数据.这时 ...
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
- PHP正则表达式详解
正则表达式定义 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串.将匹配的子串做替换或者从某个串中取出符合某个条件的子串等. 列目录时, ...
- 浅析Web Services
Web Services 可使您的应用程序成为 Web 应用程序. Web Services 通过 Web 进行发布.查找和使用. 1.什么是Web Services? Web Services 是应 ...
- nginx root与alias区别
引用于文章https://blog.csdn.net/line_aijava/article/details/71473793 root: Sets the root directory for re ...
- Django一些技巧
整数限制范围 from django.core.validators import MaxValueValidator, MinValueValidator start = models.Intege ...
- 数组和集合(三):Set集合的使用总结
一.概述 · 继承collection接口 · 无序(不记录添加顺序).不允许元素重复.只允许存在一个null元素 二.实现类 1. HashSet · 底层其实是包装了一个HashMap实现的 · ...
- memcache分布式的高速缓存系统
http://baike.baidu.com/link?url=8v9IdWg0i_ptrTfz0APh32-SbvNUAWvXrcZM5vuJ8BrjCR2oylrieOXJ3vkSuRAq3kQV ...
- SpringBoot29 登录逻辑、登录状态判断
1 知识点扫盲 浏览器和服务器之间时通过session来确定连接状态的,浏览器第一次请求时服务端会自动生成一个session,并将这个sessionId传回给浏览器,浏览器将这个sessionId存放 ...
- Mysql配置文件详解 my.cof
Mysql配置文件详解 # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/ ...