导入依赖
javax.servlet javax.servlet-api3.1.0 provided org.springframework spring-webmvc5.2.5.RELEASE com.alibaba fastjson1.2.75 com.fasterxml.jackson.core jackson-core2.9.0 com.fasterxml.jackson.core jackson-databind2.9.0 src/main/java ***.xml **/*.properties true
springMVC的配置文件
web.xml
dis
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:springMVC.xml
1
dis
*.do
@RequestMapping() 处理请求
@RequestMapping(value="/ajax4.do",produces="text/plain;charset=utf-8") 设置编码 不然中文异常 produces属性设置响应中文数据
@RequestBody 处理ajax请求 放在请求方法前
@RequestParam 解决请求数据name和接收name不一致问题 放在接收方法形参前
Public ModelAndView doOther(@RequestParam("rName") String name,String age)
解决多次冲突访问路径
访问路径 /user/aaa.jsp 响应转发到此处 再次点击会出现404 原因是 多加个 user /user/user/aaa.jsp
解决办法两种
1 在head中加入 base标签
href填入项目访问路径
2 在head加入拼接的访问路径
<%
String basePath=request.getScheme()+"://"+
request.getServerName()+":"+request.getServerPort()+
request.getContextPath()+"/";
%>



