ssm整合过程中遇到的问题

1.ssm整合设置首页

在web.xml中设置

<!-- 默认首页 -->

<welcome-file-list> <welcome-file>index</welcome-file> </welcome-file-list>

<!-- springmvc配置文件中指定视图解析器 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/"/> <property name="suffix" value=".jsp"/> </bean>

2.HTTP 404 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示

项目启动以后打开浏览器访问项目地址,显示:HTTP 404 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示的信息提示;

原因:可能是你将你所设置的首页的页面资源放在了WEB-INF下面,WEB-INF是不允许外部进行访问的。把首页资源移出来就可以了。

3.在web.xml中配置log4j2的上下文以及监听器的时候提示错误

配置完成以后启动的时候提示:ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

原因可能有如下两种:

1.context-param中关于配置文件的路径信息配置是【log4jConfiguration】而不是log4jConfigLocation。

<!--log4j2-->
    <context-param>
        <param-name>log4jConfiguration</param-name>
        <param-value>classpath:log4j/log4j2.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
    </listener>

2.web.xml中的Servlet的版本声明应该是3.0,具体如下:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">

4. 启动过程中提示:Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFile

解决办法:将log4j2.xml中的monitorInterval的值设置为0;

<configuration monitorInterval="30"> .... </configuration>

5.

原因:在Mapper.xml中对非字符串类型的数据进行了是否为空判断,如date类型的数据Create_Date != ,decimal类型的数据price != 都会报这个错误

只有字符串才需要非空判断

经验分享 程序员 微信小程序 职场和发展