SSM(源生活-大众点评后端)学习笔记
1、restful+SpringMVC+form表单:
1.1 由于form表单只支持method=post或者method=get,对于delete及put,可以
a. 添加过滤器HiddenHttpMethodFilter;
b. 在form中添加<input type="hidden" name="_method" value="DELETE">或者<input type="hidden" name="_method" value="PUT">
1.2 如果表单enctype="multipart/form-data"时,要在过滤器HiddenHttpMethodFilter前添加一个过滤器:MultipartFilter并指定multipartResolverBeanName为multipartResolver(此为springMVC文件上传解析器Bean的id),同时multipartResolver这个bean所在的配置文件要在contextConfigLocation下,才能在过滤器前将bean写入容器中
<!-- Spring配置文件开始 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-config.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring配置文件结束 -->
2、数据绑定:
2.1 controller接收参数为非自定义对象时,为了稳定,要加上@RequestParam注解;
2.2 controller方法中可以通过RedirectAttributes 的addFlashAttribute(key,value)添加内容传输到重定向controller中
3、tomcat设置uri编码:在Connector标签下添加URIEncoding="UTF-8"
4、mybatis
4.1 多对一:在多方bean添加一方bean作为属性,再在配置文件中建一个resultMap,添加 <association property="一方bean的变量名" javaType="一方bean">
<result column="字段名" property="属性名" ></result>
</association>
可以通过"一方bean的变量名"."属性名"取得此值
4.2 1对多:在一方bean添加List<多方bean>作为属性,再在配置文件中建一个resultMap对应多方bean属性,再建一个resultMap对应一方bean并添加
<collection property="List<多方bean>的变量名" resultMap="多方resultMap的id"/>
4.3 mybatis sql语句中,静态常量的用法'${@类全名@常量名}'
5、spring-task的使用:
5.1 注解方式:类上加@EnableScheduling,方法上加 @Scheduled(cron ="0 30 0 ? * *")
5.2 配置方式:<task:scheduled-tasks>
<task:scheduled ref="类名" method="方法名" cron="0 30 0 ? * *"></task:scheduled>
</task:scheduled-tasks>
6、区分ajax请求:ajax请求request.getHeadre("X-Requested-With")!=null
7、图表:echart
8、全文检索:lucene->1、Solr,2、ElasticSearch
9、推荐系统:用到的框架:3、Hadoop,4、Spark
10、境界:系统->产品->艺术品->哲理
本文来自博客园,作者:咔咔皮卡丘,转载请注明原文链接:https://www.cnblogs.com/anquing/p/17603562.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Blazor Hybrid适配到HarmonyOS系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 分享4款.NET开源、免费、实用的商城系统
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库