1.target文件夹中不能生成mapper映射文件,一直报找不到错误
原因:idea不会吧src/main/java下的配置文件打包
解决方案:
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
includes>
<filtering>truefiltering>
resource>
resources>
2.编写jsp页面时el表达式不起作用
原因:maven创建项目时,web.xml头部声明默认是2.3,这个默认jsp关闭el表达式
解决方案:isELIgnored=“false”(推荐)
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
解决方案:更换头部声明为3.0(不推荐)
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
web-app>
3.post请求到后台乱码问题
<filter>
<filter-name>CharacterEncodingFilterfilter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
<init-param>
<param-name>encodingparam-name>
<param-value>UTF-8param-value>
init-param>
<init-param>
<param-name>forceEncodingparam-name>
<param-value>trueparam-value>
init-param>
filter>
<filter-mapping>
<filter-name>CharacterEncodingFilterfilter-name>
<url-pattern>/*url-pattern>
filter-mapping>
必须添加init-param部分内容!!!!!!!!!!!!!!!!!!!
必须添加init-param部分内容!!!!!!!!!!!!!!!!!!!
必须添加init-param部分内容!!!!!!!!!!!!!!!!!!!
1.encoding:字符集,即将过滤到的request的字符集设置为encoding指定的值,相当于
request.setCharacterEncoding("")
2.forceEncoding:字面意思是强制字符集,这个参数的值是指定response的字符集是否也设置成encoding所指定的字符集,所以你可以选择设置为true或false,当值为true时,相当于
request.setCharacterEncoding("");
response.setCharacterEncoding("");
当值为false时,相当于
request.setCharacterEncoding("");
知识点
递归,树形结构
mybatis
根据部门id查出该部门信息,并且携带所有子部门信息
<select id="getChildDepartment" resultType="Department" parameterType="Integer">
SELECT * FROM department WHERE parentDepartmentid=#{departmentId}
select>
Test类
public class applicationContextTest {
private DepartmentMapper bean;
@Before
public void init(){
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
System.out.println(applicationContext.toString());
bean = applicationContext.getBean(DepartmentMapper.class);
}
void digui(List<Department> list){
for (Department department : list) {
List<Department> department1 = bean.getChildDepartment(department.getDepartmentId());
department.setChildDepartmentList(department1);
digui(department1);
}
}
@Test
public void test(){
List<Department> department = bean.getChildDepartment(12);
digui(department);
String s = JSON.toJSONString(department,true);
System.out.println(s);
}
}
结果
[
{
"childDepartmentList":[
{
"childDepartmentList":[
{
"childDepartmentList":[],
"departmentId":16,
"departmentName":"保安1部1组1个",
"departmentNo":"6666",
"parentDepartmentId":15
}
],
"departmentId":15,
"departmentName":"保安1部1组",
"departmentNo":"222222222",
"parentDepartmentId":13
}
],
"departmentId":13,
"departmentName":"保安1部",
"departmentNo":"333333",
"parentDepartmentId":12
},
{
"childDepartmentList":[],
"departmentId":14,
"departmentName":"保安2部",
"departmentNo":"444444",
"parentDepartmentId":12
}
]
答:利用HashSet
public static List removeDuplicate(List list) {
HashSet h = new HashSet(list);
list.clear();
list.addAll(h);
return list;
}
<div class="form-group">
<label for="s_province" class="col-sm-2 control-label">祖籍</label>
<div class="col-sm-3">
<select id="s_province" name="province" class="form-control"></select>
</div>
<div class="col-sm-3">
<select id="s_city" name="city" class="form-control"></select>
</div>
<div class="col-sm-3">
<select id="s_county" name="county" class="form-control"></select>
</div>
</div>
<div id="show"></div>
<script class="resources library" src="http://sandbox.runjs.cn/uploads/rs/267/g3ugugjp/area.js" type="text/javascript"></script>
<script type="text/javascript">_init_area();</script>
<script type="text/javascript">
var Gid = document.getElementById ;
var showArea = function(){
Gid('show').innerHTML = "省"
+ Gid('s_province').value + " - 市" +
Gid('s_city').value + " - 县/区" +
Gid('s_county').value + ""
}
Gid('s_county').setAttribute('onchange','showArea()');
</script>
解决方案:
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date birthday;
//去空格
$("input").blur(function () {
console.log("blur");
var trim=$(this).val().trim();
//!!!inportant一步
$(this).val(trim);
})