会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132971个问题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        ul{list-style: none;
        position: absolute;
        display: none;
        min-width: 220px;
            
        }
        li{
            cursor: pointer;
            height: 30px;
            line-height: 30px;
            }
            li:hover{
                background-color: skyblue;
            }
    </style>
</head>
<body>
<ul>
    <li>我想去吃烤鸭</li>
    <li>确认关闭本页面吗?</li>
    <li>去百度搜索页面中选中的内容</li>
    <li>弹出提示框,用户【在提示框中输入内容】然后跳转至百度进行搜索</li>
</ul>
<script>
    var ul=document.querySelector('ul');
    
    document.oncontextmenu = function (eve) {
        return false;  //return false表示事件禁用
    };
    document.onmouseup=function(eve){
        if(eve.button==2){
            ul.style.display='block';
            ul.style.left=eve.clientX+'px';
            ul.style.top=eve.clientY+'px';
       
    }else{
        ul.style.display='none';
    }
   
    }
    ul.onmousedown=function(eve){
        switch (eve.target.innerHTML) {
            case '我想去吃烤鸭':function test1(){
                alert('那就去呗');
            }
                
                break;
        
            default:
                break;
        }
        // if(eve.target.innerHTML=='我想去吃烤鸭'){
        //     alert('去吧');
        }
    
</script>
</body>
</html>

老师为啥我这个mousedown事件用swtich来判断真正触发者,点击了第一个li没反应 但是用if语句判断就可以

WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 28817楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>封装自定义ajax</title>
    <script src="js/beixiAjaxBaseUtil.js"></script>
</head>
<body>
<button>传送数据</button>
</body>
<script>
    document.querySelector('button').onclick=function(){
        beixiAjax({
            type:'get',
            url:'封装自定义Ajax.php',
            data:{
                username:'test-beixi',
                password:'test-123456'
            },
            success:function (res) {
                console.log(res);
            }
        })
    }

</script>
</html>

js

function beixiAjax(paramsObj){
    if (paramsObj.type.toLowerCase()=='get'){
        var arr=[];
        for (var pro in paramsObj.data){
            var str=pro+"="+paramsObj.data[pro];
            arr.push(str);
        }
        var canshuStr=arr.join('&');
        paramsObj.url+=paramsObj.url.indexOf('?')==-1
            ?'?'+canshuStr:
            '&'+canshuStr;

    }else if(paramsObj.type.toLowerCase()=='post'){
        var formData=new FormData;
        for (var pro in paramsObj.data){
            formData.append(pro,paramsObj.data[pro]);
        }
    }else {
        console.log('请求类型有误')
    }
    var xhr=new XMLHttpRequest();
    xhr.onreadystatechange=function () {
        if (xhr.readystate==4){
            if(xhr.status==200){
                paramsObj.success(JSON.parse(xhr.responseText));
            }
        }
    };
    xhr.open(paramsObj.type,paramsObj.url,true);
    if (paramsObj.type.toLowerCase()=='get'){
        xhr.send(null);
    }else if(paramsObj.type.toLowerCase()=='post'){
        xhr.send(formData);
    }else {
        console.log('请求有误');
    }
}

php

<?php
 $success=array('msg'=>'ok','info'=>$_GET);
 echo  json_encode($success);
?>

老师我做的这个前端没有任何反应 ,麻烦给看看哪里的问题 谢谢老师

WEB前端全系列/第六阶段:Http服务与Ajax模块(旧)/Http服务与Ajax编程 28819楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document节点练习</title>
    <!--<style type="text/css">
        ul{
            list-style: none;margin: 0;padding: 0;
        }
        ul li{
            display: inline-block;width: 100px;height: 30px;line-height: 30px;text-align: center;background-color: #0086b3;
        }
        li a{

        }
        li:hover{
            background-color: #0077aa;
        }
        li a:hover{
            color:red;
        }
    </style>-->
    <style>
        li:hover{background-color: #b3d4fc}
        li a:hover{color:red}
    </style>
</head>
<body>
<!--<ul>
    <li><a href="#">首页</a></li>
    <li><a href="#">新闻</a></li>
    <li><a href="#">军事</a></li>
    <li><a href="#">娱乐</a></li>
</ul>-->
<script>
    var arr=["首页","新闻","军事","娱乐"]
    var ulText=document.createElement('ul');
    var ulText_style= document.createAttribute('style');
    ulText_style.value="list-style: none;margin: 0;padding: 0;";
    ulText.setAttributeNode(ulText_style);
    for(var i=0;i<arr.length;i++){
        var liText=document.createElement('li');
        var liText_style= document.createAttribute('style');
        liText_style.value='display:inline-block;width:100px;height:30px;line-height:30px;\
                             text-align:center;margin-left:5px';
        liText.setAttributeNode(liText_style);

        var aText=document.createElement('a');
        var aText_style= document.createAttribute('style');
        aText_style.value="text-decoration: none;";
        aText.setAttributeNode(aText_style);
        aText.innerHTML=arr[i];
        liText.appendChild(aText);
        ulText.appendChild(liText);
    }
    document.body.appendChild(ulText);
    var arr2 = ['cnode社区也切换到let\'s encrypt了','【深圳】nodeparty 2016.04.09总结','国内nodejs2015','展望nodejs 2016','基础javascript'];
    var ul1 = document.createElement('ul');
    var ul1_style = document.createAttribute('style');
    ul1_style.value = 'height: 30px;list-style: none;padding: 0;margin: 0;';
    ul1.setAttributeNode(ul1_style);
    document.body.appendChild(ul1);
    for (var j =0;j<arr2.length;j++){
        var li1 = document.createElement('li');
        var li1_style = document.createAttribute('style');
        li1_style.value = "height: 30px;line-height: 30px;text-align: left;border-bottom: 1px solid gainsboro;";

        li1.setAttributeNode(li1_style);
        var a1 = document.createElement('a');
        a1.innerHTML = arr2[j];
        li1.appendChild(a1);
        ul1.appendChild(li1);
    }
</script>
</body>
</html>

这样写的话应该是没有什么问题的吧

WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 28823楼

老师帮忙看下哪里出错

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.NullPointerException

### The error may exist in com/bjsxt/mapper/UsersMapper.xml

### The error may involve com.bjsxt.mapper.UsersMapper.selectByPrimaryKey

### The error occurred while executing a query

### Cause: java.lang.NullPointerException

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)

at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)

at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:152)

at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)

at com.sun.proxy.$Proxy4.selectByPrimaryKey(Unknown Source)

at com.bjsxt.service.impl.UsersServiceImpl.selectUsersById(UsersServiceImpl.java:17)

at com.bjsxt.test.TestSelect.selectUsersById(TestSelect.java:16)

at com.bjsxt.test.TestSelect.main(TestSelect.java:10)

Caused by: java.lang.NullPointerException

at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936)

at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:964)

at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:230)

at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:223)

at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:219)

at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:95)

at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:432)

at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)

at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:139)

at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:61)

at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337)

at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)

at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)

at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)

at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)

at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)

... 9 more

null

mybatisdemo5_Generator.rar


JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 28826楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程和并发编程(旧) 28828楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637