做了一个屏蔽进数据库的操作:

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&amp;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的更多相关文章

  1. (一)SpringMVC之警告: No mapping found for HTTP request with URI

    这个警告往往是因为url路径不正确. 所以从三个地方下手: 1.springmvc-config.xml中的配置handle,看看是不是因为handle没有配置导致的. 2.如果是使用注解的方式的话, ...

  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 ...

  3. 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法

    首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. '/'和‘/*’差异造成的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 ...

  8. SpringMvc出现No mapping found for HTTP request with URI的终极解决办法

    No mapping found for HTTP request with URI 出现这个问题的原因是在web.xml中配置错了,如: <servlet> <servlet-na ...

  9. 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 ...

随机推荐

  1. 1102 Invert a Binary Tree

    题意:给定一个二叉树,要求输出翻转后的二叉树的层序序列和中序序列. 思路:不用真的翻转,只需要在输出时先访问右结点再访问左结点即可. 代码: #include <cstdio> #incl ...

  2. 安装SQL Servre2000时提示“command line option syntax error! type command /? for help”

    问题: 当程序正在安装ms数据访问组件时,弹出错误提示框:command line option syntax error,type command/? for help,点击确定继续:到了程序正在安 ...

  3. 网络 、osi 七层模型、tcp/ip 五层参考

    网络 网络的本质就是通讯,比特传输 网络拓扑 物理布局pc -- 交换机 -- 路由器逻辑布局pc -- 路由器 交换机的产生 网络之初,是通过网线互相连通到各个主机,存在的问题就是2个pc都要与服务 ...

  4. MongoDB day01

    MongoDB芒果数据库 数据存储阶段 文件管理阶段(.txt .doc .xlc) 优点:数据可以长期保存:数据有一定格式化规范:可以大量存储:使用简单方便 缺点:数据一致性差:用户查找修改不方便: ...

  5. 【UVA】10391 Compound Words(STL map)

    题目 题目     分析 自认已经很简洁了,虽说牺牲了一些效率     代码 #include <bits/stdc++.h> using namespace std; set <s ...

  6. wamp-php 集成环境的基础配置

    域名访问设置(本地局域网) 用记事本打开 127.0.0.1是本地回环地址 配置完后 通过在本地浏览器输入www.0705.com就可以访问本地站点了 Wamp集成环境多站点配置 配置条件: 一个服务 ...

  7. mysqldumpl备份

    mysqldump --databases mydatabase --lock-all-tables --flush-logs mysqldump -h10. -uroot -p密码 --databa ...

  8. canvas获取鼠标位置

    canvas获取鼠标位置 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  9. Tkinter Relief styles(样式)

      Tkinter Relief styles: 构件的浮雕式是指某些模拟的3-D周围的部件外的影响.下面是一排按钮的屏幕截图展示了所有可能的救济风格   构件的浮雕式是指某些模拟的3-D周围的部件外 ...

  10. opennebula onenebula

    http://www.eucalyptus.com/blog/2013/01/07/opennebula-38-%E2%80%94-%E7%9B%91%E6%8E%A7 [云监控] http://ww ...