action怎么写

来源:趣味经验馆 1.53W
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里面就是: 呵呵,希望你能够成功哦。

热门标签