例如 页面加载时 在入口函数里 写一个异步请求,向后台要数据,就比如是 街道的选择列表,把这个列表的数据作为 Select 的option 字标签。 然后需要设置某一个 街道的信息被选中。
$("#select标签的ID").val(后台传的值,也是该街道名称的value)
注意把这行代码放在异步请求的成功的回调函数内部。 避免代码不同步 导致事实和预期不相符。
Jquery 的一些知识:
$("#street>option:gt(0)").remove();
表示 id 为street 的元素,删除它下面的所有的option子节点,但不包含第一 个子节点,gt(0)就是排除第一个的意思。
parseInt($("#span").val())
表示的是 获取id 为span 的元素的值,将这个值转为整数(number)
$(“table tr:eq(1)”).remove();
这个的意思为 删除 table 标签下的(tr) 第二行。eq(index) 匹配索引,索引从0开始。如果一个页面有多个table标签,则注意需要给标签取id
分布式项目中 怎么做单元测试????
public class Test {
public static void main(String[] args) {
//有了spring以后,所有的业务对象不能自己实例化,只能从spring容器中获取对象
ApplicationContext ctx=new ClassPathXmlApplicationContext(“classpath*:applicationContext-*.xml”);
DistrictService districtService=(DistrictService)ctx.getBean(“districtServiceImpl”);
List<District> list=districtService.getAllDistrict();
//显示
list.forEach(district -> {
System.out.println("区域名称:"+district.getName());
});
}
}