国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

Spring與Struts整合之讓Spring管理控制器操作示例

2024-07-09 22:43:07
字體:
來源:轉載
供稿:網友

本文實例講述了Spring與Struts整合之讓Spring管理控制器操作。分享給大家供大家參考,具體如下:

一 Web配置

<?xml version="1.0" encoding="GBK"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">  <!-- 使用ContextLoaderListener初始化Spring容器 -->  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener    </listener-class>  </listener>  <!-- 定義Struts 2的FilterDispathcer的Filter -->  <filter>    <filter-name>struts2</filter-name>    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  </filter>  <!-- FilterDispatcher用來初始化Struts 2并且處理所有的WEB請求。 -->  <filter-mapping>    <filter-name>struts2</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping></web-app>

二 applicationContext.xml配置

<?xml version="1.0" encoding="GBK"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://www.springframework.org/schema/beans"  xmlns:p="http://www.springframework.org/schema/p"  xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">  <!-- 定義一個業務邏輯組件,實現類為MyServiceImp -->  <bean     class="org.crazyit.app.service.impl.MyServiceImpl"/>  <!-- 讓Spring管理的Action實例,并依賴注入業務邏輯組件 -->  <bean  class="org.crazyit.app.action.LoginAction"    scope="prototype" p:ms-ref="myService"/></beans>

三 視圖

1 loginForm.jsp

<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %><%@taglib prefix="s" uri="/struts-tags"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>  <title>登錄頁面</title></head><body><h3>用戶登錄</h3><s:form action="login">  <s:textfield name="username" label="用戶名"/>  <s:textfield name="password" label="密碼"/>  <tr align="center">    <td colspan="2">    <s:submit value="登錄" theme="simple"/>    <s:reset value="重設" theme="simple"/>    </td>  </tr></s:form></body></html>

2 welcome.jsp

<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %><%@taglib prefix="s" uri="/struts-tags"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>  <title>成功頁面</title></head><body>  您已經登錄!<br/>  <s:actionmessage /></body></html>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彝良县| 永修县| 盐池县| 文登市| 桦甸市| 鸡泽县| 丰县| 九龙县| 阜新市| 沛县| 龙岩市| 安丘市| 澎湖县| 曲阳县| 遂宁市| 如东县| 乌兰浩特市| 潮安县| 兴化市| 积石山| 乐昌市| 陈巴尔虎旗| 苏州市| 古田县| 绥宁县| 镇原县| 洱源县| 五家渠市| 高平市| 缙云县| 九台市| 河北区| 都兰县| 赤水市| 海盐县| 巴东县| 股票| 阿鲁科尔沁旗| 翼城县| 云阳县| 巴塘县|