SSH框架專案總結

飛來的賊發表於2017-12-03

Struts1 

Action需要在檔案中配置路徑和path,在forward中加入對映的頁面.

Action類要繼承StrutsAction     在action 中加入 parameter="method" 路徑加入對應的執行方法

  	<action name="memberForm" path="/memberAction"
			type="cn.com.duc.ds.member.struts.action.MemberAction"
			parameter="method" scope="request">
			<forward name="member_edit"
				path="/member_edit.jsp" />
			<forward name="member_shenpi"
				path="/member_shenpi.jsp" />
		</action>
地址:localhost:8080/web/memberAction.do?method=execute1
如果需求中不需要路徑中帶有method方法

Action繼承StrutsAction     預設執行execute()

Spring

配置檔案讀取

<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:db.properties</value>
				<value>classpath:common.properties</value>
			</list>
		</property>
	</bean>
方便使用,已經裝配到類中屬性

		<property name="driverClass">
			<value>${jdbc.driver}</value>
		</property>
		<property name="jdbcUrl">
			<value>${jdbc.url}</value>
		</property>
		<property name="user">
			<value>${jdbc.username}</value>
		</property>
		<property name="password">
			<value>${jdbc.password}</value>
		</property>
Spring bean 中注入

<bean id="ShareLoginService"
		class="cn.com.ShareLoginServiceImpl"
		autowire="byName">
		   <property name="verify" value="${TextSecretkey}"/>
		</bean>

相關文章