SpringMVC的問題No mapping found for HTTP request with URI

來源:互聯網
上載者:User

標籤:source   driver   val   3.2   blog   back   path   llb   crm   

做了一個屏蔽進資料庫的操作:

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>
@Overridepublic 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.