1. 程式人生 > >ajax使用時的錯誤the server responded with a status of 404 (Not Found)

ajax使用時的錯誤the server responded with a status of 404 (Not Found)

使用ajax跳轉方法時,頁面ctrl+shift+i除錯報告了一個404錯誤,說找不到方法。頁面位址列直接指向方法的地址跳轉也是404。目標方法是新增的,於是使用複製黏貼,確定各處方法名稱一致之後,重啟server。 
除錯時再次報錯:

jquery.min.js Failed to load resource: the server responded with a status of 404 (Not Found) 
send @ jquery.min.js:4 


這次的錯誤 在後臺打印出了錯誤的原因:

 Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*)
        FROM  web114_keyword_rele r
        where r.del_flag ='0'

 ' at line 1

出錯的xml語句為:

<select id="countReleSet" parameterType="java.util.HashMap" resultType="java.lang.Integer">
        SELECT COUNT (*)
        FROM  web114_keyword_rele r
        where r.del_flag ='0'
        <if test="keyId != null">
            and r.key_id = #{keyId,jdbcType=VARCHAR},
        </if>
        <if test="storeId != null">
            and r.store_id = #{storeId,jdbcType=VARCHAR}
        </if>
    </select>

一開始沒反應過來錯在哪裡,就把語句扔到mysql裡面跑了一遍,其實是count和(*)之間不應該有間隔,把語句改成

<select id="countReleSet" parameterType="java.util.HashMap" resultType="java.lang.Integer">
        SELECT COUNT(*)
        FROM  web114_keyword_rele r
        where r.del_flag ='0'
        <if test="keyId != null">
            and r.key_id = #{keyId,jdbcType=VARCHAR},
        </if>
        <if test="storeId != null">
            and r.store_id = #{storeId,jdbcType=VARCHAR}
        </if>
    </select>

即可。簡直是一個愚蠢的錯誤。。。。。。 
寫xml語句的時候,還是放到mysql裡面跑一跑,確定沒有語法問題再放進來。要不然後面報錯了再除錯還是挺討厭的

本部落格是博主轉載自: https://blog.csdn.net/sinat_32034679/article/details/72763333