创建人 | 陈思淀 |
问题标题 | Servlet的XML配置 |
问题分类 | 配置文件问题 |
一级话题 | |
问题补充 | |
附件 | <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <servlet> <servlet-name>demo1</servlet-name> <servlet-class>ServletDemo2</servlet-class> </servlet> <servlet-mapping> <servlet-name>demo1</servlet-name> <url-pattern>/demo1</url-pattern> </servlet-mapping> </web-app> |
问题答案 | 问题分析: 编写不报错,无法显示前端页面 |
问题解决方法: 使用copy reference 方法拷贝类名,拷贝到xml文件的<servlet-class>当中,保证class中存在包名和完整类名。 |
创建人 | 陈思淀 |
问题标题 | 格式问题 |
问题分类 | 代码编写错误 |
一级话题 | IllegalArgumentException |
问题补充 | public class DruidUtils { private static DataSource ds; static{ try { Properties pro = new Properties(); pro.load(DruidUtils.class.getClassLoader().getResourceAsStream("druid.properties")); DataSource ds = DruidDataSourceFactory.createDataSource(pro); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } public static Connection getConnection() throws SQLException { return ds.getConnection(); } public static DataSource getDataSource(){ return ds; } public static void close(ResultSet rs, Statement stmt,Connection conn){ if (rs!=null){ try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if (stmt!=null){ try { stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn!=null){ try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } |
附件 | |
问题答案 | 问题分析: 代码编写错误 |
问题解决方法: 注意ds对象不能反复创建,只需要重新赋值,删去DataSource修饰即可。 |
创建人 | 陈思淀 |
问题标题 | 代码书写问题 |
问题分类 | 无法倒计时 |
一级话题 | |
问题补充 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <style> span { color: red; } p { text-align: center; } </style> <body> <p><span id="time">5</span>秒钟跳转到首页...</p> <script> var time = document.getElementById("time"); var second = 5; function countDown() { second--; if (second = 0) { location.href = "tlias-stu.boxuegu.com/#/login"; } time.innerHTML = second + ""; } setInterval(countDown, 1000); </script> </body> </html> |
附件 | |
问题答案 | 问题分析: 发现second 不能使用= 进行数值判断,必须使用==。 |
问题解决方法: 修改=为==。 |
创建人 | 陈思淀 |
问题标题 | 页面显示问题 |
问题分类 | |
一级话题 | |
问题补充 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="js/jquery-3.2.1.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="js/bootstrap.js"></script> <style> .search-bar { vertical-align: center; margin-top: 20px; } hr { color: yellow; height: 5px; width: 100%; } .jx { border-bottom: 2px solid yellow; padding: 5px; } .paddingtop { margin: 10px } .footer{ background-color: yellow; height: 60px; text-align:center; line-height: 60px; font-size: 16px; } </style> </head> <body> <div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> <li><a href="#">Link</a></li> </ul> </div> <br><br><br> <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="img/banner_1.jpg" alt="..."> <div class="carousel-caption"> banner1 </div> </div> <div class="item"> <img src="img/banner_2.jpg." alt="..."> <div class="carousel-caption"> banner2 </div> </div> <div class="item"> <img src="img/banner_3.jpg." alt="..."> <div class="carousel-caption"> banner3 </div> </div> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> |
附件 | |
问题答案 | 问题分析: 显示页面在轮播图翻页时震动 |
问题解决方法: 在轮播图前面的导航栏之后加上几行换行符 |
创建人 | 陈思淀 |
问题标题 | 格式错误 |
问题分类 | 无法查找到正确的xml内标签 |
一级话题 | |
问题补充 | |
附件 | public class XpathDemo { public static void main(String[] args) throws XpathSyntaxErrorException, IOException { String path = XpathDemo.class.getClassLoader().getResource("student.xml").getPath(); Document document = Jsoup.parse(new File(path), "utf-8"); JXDocument jxDocument= new JXDocument(document); List<JXNode> jxNodes = jxDocument.selN("//student[@number='s001']"); for (JXNode jxNode : jxNodes) { System.out.println(jxNode); } } } |
问题答案 | 问题分析: 代码中getResource方法直接写入了文件名,应当输入此文件在项目中的路径名 |
问题解决方法: 使用路径名 |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |