javaweb面试题

1.JS获取元素的几种方式

①.var tag= docum.getElementById("id");//id获取

②.var tag = document.getElementByTagName("标签名");//通过标签名,返回类数组

③.var tag = document.getElementByTagName("属性名");//属性名获取,返回数组

④.var tag = document.getElementByClassName("类名");//类获取,返回数组

2.Jquery选择元素的方式

①.var tag= $("#id")//id选择器

②.var tag=$(#.类名)//类选择器

③.var tag=$(#标签名)//标签选择器,返回数组

3.input获取地址栏参数值:value=${param.参数名}

       var obj1={
                id:123,
                name:"test",
                toString:function(){
                    return "test";
                }
            }
            var o = "test";
            alert(o==obj1);//true判断值是否相等
            alert(o===obj1);//false//判断值和类型是否相等

4. onmouseover与onmousemove的区别是:当鼠标移过当前对象时就产生了onmouseover事件(onmouseover有个移入移出的过程),当鼠标在当前对象上移动时就产生了onmousemove事件,只要是在对象上移动而且没有移出对象的,就是onmousemove事件

5.js获取select选中的选项的值

var tag = document.getElementById("select的id");//获取select对象

var index = tag.selectedIndex//获取选中的索引

var text =  tag.options[index].text;//获取文本

var value =  tag.options[index].value;//获取value

JQuery获取:

第一种方式
$('#testSelect option:selected').text();//选中的文本

$('#testSelect option:selected') .val();//选中的值

$("#testSelect ").get(0).selectedIndex;//索引

第二种方式
$("#tesetSelect").find("option:selected").text();//选中的文本
…….val();
…….get(0).selectedIndex;

6.servlet和jsp关系:jsp通过servlet的out.printer将HTML标签打出来,jsp的底层实现就是servlet

web应用servlet必须继承HTTPServlet,实现service方法,如下:

public class LoginAction extends HttpServlet{
    public void service(HttpServletRequest request,HttpServletResponse response)
        throws ServletException,IOException{xxx}

 7.jsp有哪些动作

jsp:include:在页面被请求的时候引入一个文件。
includ两种方法的实现 :
有两种实现方法,动态,静态。
动态:用于包含动态页面,并且可以随时检查页面的变化,采用jsp:include动作可以实现,例如:
   <jsp:includepage="***.jsp" flush="true"/>
静态,适合于包含静态页面,不检查页面的变化,采用include伪码实现
  <%@include file="***.html"%>
jsp:useBean:寻找或者实例化一个JavaBean。
jsp:setProperty:设置JavaBean的属性。
jsp:getProperty:输出某个JavaBean的属性。
jsp:plugin:根据浏览器类型为Java插件生成OBJECT或EMBED标记。
jsp:forward:把请求转到一个新的页面。
--------------------- 
原文地址:https://www.cnblogs.com/lhc-hhh/p/10289471.html