您的位置:首页 > 编程语言 > Java开发

Java-SpringMVC 项目配置注意事项

2017-02-21 11:16 363 查看
使用Intellij idea创建maven+springmvc项目报错,遇到了大概就是有关tomcat端口占用之类的错误信息:



解决办法: 在xxx-servlet.xml配置文件中能手敲就不要复制

例如:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 
<context:component-scan base-package="com.mark.controller" />
<!-- 静态资源(js、image等)的访问 -->
<mvc:default-servlet-handler/>

<!-- 开启注解 -->
<mvc:annotation-driven/>

<!--ViewResolver 视图解析器-->
<!--用于支持Servlet、JSP视图解析-->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>

</beans>


其中:

xmlns:mvc="http://www.springframework.org/schema/mvc"
和
//这一句如果手敲的话,xmlns:mvc之类的会自动生成,项目运行就没有问题
//如果直接粘贴过来 项目运行肯定报错
<mvc:default-servlet-handler/>


被这里坑死了……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息