毕设:高校考试信息数字化平台(一)——SpringMVC的配置

本篇随笔参考自:http://www.cnblogs.com/bigdataZJ/p/springmvc1.html   以及  http://blog.csdn.net/kkdd2013/article/details/52441013

eclipse的配置可见上两篇文章


 

毕设主要研究内容:

  1.使用SpringMVC框架进行开发基于B/S架构的高校考试信息数字化平台。

  2.主要前端技术是Html+Css,使用Bootstrap框架,提高界面美观度。

  3.数据库使用MySql,使用广泛且方便。

  4.使用Git进行项目管理,以保证项目的逐步开发。

  5.后端使用Servlet与JSP技术与前端进行数据交互。

  6.主要功能模块应该包括:考试数据统计,考试管理和信息查询等,学生选课信息管理,用户注册和登录。


 

下载SpringMVC

  • 进入下载目录 : https://repo.spring.io/release/org/springframework/spring/
  • 先进入官网 : https://projects.spring.io/spring-framework/      网页右侧的版本号选择reference  找到 Distribution Zip Files  提示:Ctrl+F可以快速搜索页面文本内容
  • 找到想下载的版本,下载spring-framework-x.x.x.RELEASE-dist.zip
  • 解压之后的文件里选择以下需要依赖的包在WEB-INF目录下新建lib文件夹,并将上面的jar包放入其中并且build
    • spring-aop-4.0.4.RELEASE.jar
    • spring-beans-4.0.4.RELEASE.jar
    • spring-context-4.0.4.RELEASE.jar
    • spring-core-4.0.4.RELEASE.jar
    • spring-expression-4.0.4.RELEASE.jar
    • spring-web-4.0.4.RELEASE.jar
    • spring-webmvc-4.0.4.RELEASE.jar

配置文件

    web.xml(WEB-INF下)

 

 

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 5     id="WebApp_ID" version="2.5">
 6     
 7     <!-- 配置DispatchcerServlet -->
 8     <servlet>
 9         <servlet-name>springDispatcherServlet</servlet-name>
10         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
11         <!-- 配置Spring mvc下的配置文件的位置和名称 -->
12         <init-param>
13             <param-name>contextConfigLocation</param-name>
14             <param-value>classpath:springmvc.xml</param-value>
15         </init-param>
16         <load-on-startup>1</load-on-startup>
17     </servlet>
18     
19     <servlet-mapping>
20         <servlet-name>springDispatcherServlet</servlet-name>
21         <url-pattern>/</url-pattern>
22     </servlet-mapping>
23     
24 </web-app>

 

12-15行说明自己会新建一个sringmvc.xml的配置文件,也可以不写这个init标签,使用默认的,/WEB-INF/[servlet-name]-servlet.xml,我就是使用默认的。

 

[servlet-name]-servlet.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 4     xmlns:mvc="http://www.springframework.org/schema/mvc"
 5     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 6         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 7         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
 8 
 9     
10     <!--配置自动扫描的包 -->
11     <context:component-scan base-package="com.test.springmvc" />
12 
13     <!--配置视图解析器:如何把handle方法返回值解析为实际的物理视图 -->
14     <bean
15         class="org.springframework.web.servlet.view.InternalResourceViewResolver">
16         <property name="prefix" value="/WEB-INF/views/" />
17         <property name="suffix" value=".jsp" />
18     </bean>
19 
20 </beans>

行4不能少,我就因为看有一篇博客里没有写这一行,就一直无法成功运行,纠结了很久,所以一定要完整,多看几篇博客综合参考。

其他更多的运行需要的配置就去看我文章顶部的链接吧,我也是新手,正在一边学习一边做毕设, 就不误导大家了哈~

 

posted @ 2018-03-19 10:44  Traveller_Leon  阅读(181)  评论(0编辑  收藏  举报