綜合知識

當前位置 /首頁/綜合知識 > /列表

action怎麼寫

1. 登陸的Action怎麼寫

/**

action怎麼寫

* 登錄

*

* @param mapping

* @param form

* @param request

* @param response

* @return

*/

public ActionForward doLogin(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) {

Users users = new Users();

users.setUserName(request.getParameter("userName"));

users.setPassword(request.getParameter("password"));

users = userBiz.userLogin(users);

if (users != null) {

request.getSession().setAttribute("users", users);

return mapping.findForward("index");

}

return mapping.findForward("login");

}

2. java中的action怎麼寫

public interface Actionextends ActionListener

Action 接口提供 ActionListener 接口的一個有用擴展,以便若干控件訪問相同的功能。

除了 ActionListener 接口定義的 actionPerformed

方法之外,此接口還允許應用程序在一個位置定義:

描述函數的一個或多個文本字符串。這些字符串可用於顯示按鈕的立體文本、在菜單項中設置文本等等。

描述函數的一個或多個圖標。這些圖標可用於菜單控件中的圖像,或者用於更復雜用户界面中的合成項。

功能的啟用/禁用狀態。應用程序可以禁用實現此接口的函數,而不必分別禁用菜單項和工具欄按鈕。所有為偵聽狀態更改而註冊為偵聽器的組件都將禁止為該項生成事件,並相應地修改顯示。

可以將此接口添加到現有類中,或者用它創建一個適配器(通常通過子類化 AbstractAction 來實現)。然後可以將

Action 對象添加到多個可感知 Action 的容器中,並連接到可容納

Action 的組件。然後可以通過調用 Action 對象的 setEnabled

方法立刻激活或取消激活 GUI 控件。

注意,Action 實現在存儲方面的開銷比典型的 ActionListener

要高,但後者不具有集中控制功能和廣播屬性更改的優點。因此,應該注意只在需要這些優點的地方使用 Action,在別處使用

ActionListener 即可。

支持 Action 的 Swing 組件

許多 Swing 的組件都具有 Action 屬性。在組件上設置 Action

時,會發生以下幾種情況:

Action 被作為 ActionListener 添加到組件。

組件配置自身的某些屬性以匹配 Action。

組件在 Action 上安裝 PropertyChangeListener,這樣組件可更改其屬性以反映 Action 屬性中的更改。

3. jsp action怎麼寫 很簡單

<servlet-mapping>

<servlet-name>action</servlet-name>

<url-pattern>/action</url-pattern>

</servlet-mapping>

表單中的action的寫法:/action;和<url-pattern>;標籤中的值一致,myeclipse中生成的JSP頁面開頭都有String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

<head>;標籤內有<base href="<%=basePath%>">

如果<head>;中沒有上述內容,action寫成<%=basePath%>/action最保險

4. action裏該寫什麼

給你個實例參考一下,細節另外處理:

<form name="form2" action="">

跳轉到:<input type="text" name="page" size="2"/>

<input type="button" name="button" value="go" onclick="check(document.form2)"/><;!--這裏不使用submit類型-->

</form>

<script>

function check(formobj){

formobj.action="menu_index_top.jsp?t_type="+formobj.page.value;

formobj.submit();

}

</script>

或者:

<form name="form2" action=""method="post" onSubmit="return check(this)"><;!--這裏應指出提交方式否則可能出現錯誤-->

跳轉到:<input type="text" name="page" size="2"/>

<input type="submit" name="submit" value="go"/>

</form>

<script>

function check(formobj){

formobj.action="menu_index_top.jsp?t_type="+formobj.page.value;

return true;

}

</script>

======================================================

不指出,地址欄可能出現&submit=go

5. form表單提交裏面的action怎麼寫

你説的是action層獲取form表單提交上來的數據嗎?

提供一種方法:

控制層相關代碼:request.getParameter("userName");

(注:userName是from表單中name屬性的值)

jsp頁面中form表單相關代碼:

6. 關於struts2的 action怎麼寫

額 看不懂你説的哦

不過struts2中的action最普遍要繼承ActionSupport這個類,而你們老師繼承ServletRequestAware類反正我們用過,然後就是定義實體類,和藉口的方法。在spring中注入

struts2中的方法以public String +方法名(){return "111";}來進行操作 return 裏面的字符串要和你struts2配置中的那個<result name="111">;/頁面的位置</result>;中的name屬性相同,你在登錄頁面的form中調用你寫的“方法名”就進入方法中如果成功返回“111”就會進入你所設置的頁面位置。

7. 關於struts2的 action怎麼寫,

呵呵,這個要看你的Struts-config.xml裏面是怎麼配置的了,你可以在配置文件裏面配置Action的參數,name="這裏是你要訪問的Action的名字,也就是你在from表單裏面的" class="這裏是你的Action的路徑" method="這個是你在Action裏面的你要訪問的方法名字" 。

比如: 那麼from裏面就是: 呵呵,希望你能夠成功哦。

TAG標籤:action #