【踩坑记录】web项目遇到的问题笔记

1、提交表单时提示错误400,控制台未报错

情况1:由于表单内容数据类型问题,无法将输入的String类型转为int类型并提交。

情况2:由于要求输入int类型的参数,而输入的数超过int范围,溢出。

情况3:提交的表单数据有属性名和POJO类中的属性名不匹配。

 

2、项目拆分时,将dao层相关的接口和xml拆分到新module,在调用dao层方法时提示错误500,找不到指定方法。

网上大多解决方法是检查xml中的namespace名和dao层接口中方法名是否一致,经排查不是此类错误。

后经过实验发现,在spring配置文件中配置sqlSessionFactory指定mybatis映射文件时,如果当前模块被依赖,则不能使用*.xml这种形式配置映射文件,而要使用全路径!

3、SpringMVC开启定时任务(SpringMVC自带定时任务)

在servlet.xml中加入

<task:annotation-driven/>

创建需要的定时任务如下:
 

@Component
public class RefreshStaticPage {
    @Scheduled(cron = "0/5 * * * * *")
    public void task(){
        //业务代码
    }
}

其中cron表示任务执行的时间:

"0/10 * * * * ?" 每10秒触发 

"0 0 12 * * ?" 每天中午12点触发 
"0 15 10 ? * *" 每天上午10:15触发 
"0 15 10 * * ? 2005" 2005年的每天上午10:15触发 
"0 * 14 * * ?" 在每天下午2点到下午2:59期间的每1分钟触发 
"0 0/5 14 * * ?" 在每天下午2点到下午2:55期间的每5分钟触发 
"0 0/5 14,18 * * ?" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发 
"0 0-5 14 * * ?" 在每天下午2点到下午2:05期间的每1分钟触发 
"0 10,44 14 ? 3 WED" 每年三月的星期三的下午2:10和2:44触发 
"0 15 10 ? * MON-FRI" 周一至周五的上午10:15触发 
"0 15 10 15 * ?" 每月15日上午10:15触发 
"0 15 10 L * ?" 每月最后一日的上午10:15触发 
"0 15 10 ? * 6L" 每月的最后一个星期五上午10:15触发 
"0 15 10 ? * 6L 2002-2005" 2002年至2005年的每月的最后一个星期五上午10:15触发 
"0 15 10 ? * 6#3" 每月的第三个星期五上午10:15触发 
每隔5秒执行一次:*/5 * * * * ? 
每隔1分钟执行一次:0 */1 * * * ? 
每天23点执行一次:0 0 23 * * ? 
每天凌晨1点执行一次:0 0 1 * * ? 
每月1号凌晨1点执行一次:0 0 1 1 * ? 
每月最后一天23点执行一次:0 0 23 L * ? 
每周星期天凌晨1点实行一次:0 0 1 ? * L 
在26分、29分、33分执行一次:0 26,29,33 * * * ? 
每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ? 

 

4、加载js文件时失败

404错误The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

解决:project —> rebuild project 再重新启动项目。

 

5、解决 Could not resolve placeholder 'xxx' in string value "${xxx}" 

一般来说报Could not resolve placeholder 'xxx' in string value "${xxx}" 错误的原因都是由于项目中有多个地方的xml文件中用到了

<context:property-placeholder location="classpath:xxx.properties"/>

或者是 

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

来引入配置文件,这时需要在这两条配置后分别加上 

<context:property-placeholder location="classpath:xxx.properties" ignore-unresolvable="true"/>

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="true">

来防止程序不能识别配置属性,加上之后配置文件中的属性就能正确识别了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值