struts1整合ajax技術

2021-08-30 14:44:57 字數 995 閱讀 7405

1.寫乙個繼承actionservlet的類a。在該類a中重寫httpservlet的service方法,然後呼叫actionservlet中的process方法,然後從requst中得到要返回給前台的值value,如果不為空,則用response. getwriter().print(value);

2.修改web.xml中的名為action的servlet中servlet-class路徑為類a的包名+a.

3.在業務action中把execute方法的返回值設為null,把要返回到前台的物件存放到request中,使類a中的service方法能得到。

4.在寫struts-config.xml檔案的action時,不用寫forward。

重寫httpservlet中的service方法:

public class controllerservlet extends actionservlet

}}

建立 乙個測試action

bean:

public class loginactionform extends actionform

public void setusername(string username)

public string getpassword()

public void setpassword(string password)

public static long getserialversionuid()

}

web.xml檔案內容如下

struts1

com.cronie.struts.controllerservlet

js如下:

index頁面如下:

struts-config.xml 內容如下:

Spring 和struts1 整合的三種方式

spring 和 struts1 整合的三種方式。1,使用spring 的 actionsupport 2,使用spring 的 delegatingrequestprocessor 類。3,全權委託。無論用那種方法來整合第一步就是要為struts來裝載spring的應用環境。就是在 struts ...

spring整合struts1三種方式

spring和struts整合方式 1 最簡單方式 struts 來裝載spring 的應用環境。就是在struts 中加入乙個外掛程式。struts config.xml 中 幾乎與 struts 無關了,相當於為整合專案加入 spring 支援,將 的配置放在 web.xml 中了 contex...

Struts 2整合Spring 經典

struts 2整合spring struts 2框架為整合其他技術提供了良好的可擴充套件性,可以通過外掛程式的方式來實現同spring技術的整合。13.2.1 整合步驟 struts 2框架整合spring很簡單,下面是整合的步驟。1 複製檔案。複製struts2 spring plugin x ...