①直接把参数名写在方法的参数中

②如果传递的参数很多,这是一个可以封装的实体类

?③处理时间参数

@Date
public class User{
private String username;
private String password;
private String realname;
private String sex;
@DateTimeFormat(pattern="yyyy-MM-dd")//把前端传递的参数转为该格式
private Date birthday;
}
④乱码
1.自定义乱码
2.使用springmvc自带的过滤器
<?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_4_0.xsd"
version="4.0">
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name><!--名字这能是这个-->
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/**</url-pattern><!--拦截所有-->
</filter-mapping>
</web-app>
⑤在WEB-INF

凡是在WEB-INF下的内容只能通过请求转发访问到。重定向访问不了该目录下的内容。
?
|