軟件工程綜合實踐階段小結(2)
這兩天,在企業導師的指導下,我們基於springmvc+mybatis+spring再次建立了之前的網站(但沒有連接數據庫)。
可以發現,結構比之前簡單了許多,事實上代碼量也小了很多。
首先在pojo包內黏貼了之前建立的Userinfo實體類,用於記錄和接受用戶信息
然後完成了springmvc.xml的配置,具體內容如下
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
<!-- 配置Controller -->
<bean id="UsersController1" name="/users.action" class="cn.neusoft.controller.UsersController1"></bean>
<!-- 項目中一般使用 掃描包的方式 進行 配置 -->
<context:component-scan base-package="cn.neusoft.controller"></context:component-scan>
<!-- 實際開發中使用 加載註解的 適配器、映射器 、 Json轉換器 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 非註解的 映射器 以及 適配器 -->
<!-- 配置處理器映射器 -->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>
<!-- 配置處理器適配器 -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
<!-- 另外一個適配器 -->
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean>
<!-- 配置視圖解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 配置jsp 頁面的前綴 -->
<property name="prefix" value="/WEB-INF/jsp"></property>
<!-- 配置後綴 -->
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
然後在controller包中使用模擬的數據庫完成率值的傳遞
然後仿照之前的內容完成了user.jsp和user2.jsp兩個網頁的設計
運行結果
軟件工程綜合實踐階段小結(2)