You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "udaykumar (JIRA)" <ji...@apache.org> on 2008/03/13 11:28:07 UTC
[jira] Updated: (WW-2552) How to use the 'struts 1 plugin' in
struts2
[ https://issues.apache.org/struts/browse/WW-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
udaykumar updated WW-2552:
--------------------------
Component/s: (was: Example Applications)
Core Actions
> How to use the 'struts 1 plugin' in struts2
> -------------------------------------------
>
> Key: WW-2552
> URL: https://issues.apache.org/struts/browse/WW-2552
> Project: Struts 2
> Issue Type: New Feature
> Components: Core Actions
> Affects Versions: 2.0.11.1
> Environment: windows xp,tomcat5.5,servlet2.4,struts2.0.11
> Reporter: udaykumar
>
> Hi
> I'm Trying to use ActionForm and Action class in my struts2. I Used the struts 1 plugin for this. I followed the procedure, which they given. Still i'm finding error in this.
> I'm giving my entire application here.
> strutslogin.jsp
> -------------------
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <%@ page language="java" contentType="text/html"%>
> <html>
> <head>
> <title>Insert Data here!</title>
> <link href="<s:url value="/css/main.css"/>" rel="stylesheet"
> type="text/css"/>
> </head>
> <body>
> <s:form action="/struts1/logon.action" method="POST" name="form1">
> <s:textfield name="userId" label="Login Id"/><br>
> <s:password name="password" label="Password"/><br>
> <s:submit value="Login" align="center"/>
> </s:form>
> </body>
> </html>
> ----------------------------
> MyForm.java
> ----------------------------
> package com;
> import org.apache.struts.action.ActionForm;
> public class MyForm extends ActionForm{
> public String userId;
> public String password;
> public String getUserId() {
> return userId;
> }
> public void setUserId(String userId) {
> this.userId = userId;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String password) {
> this.password = password;
> }
> }
> -------------------
> MyAction.java
> ---------------------
> package com;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> public class MyAction extends Action{
> public ActionForward execute( ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res)
> {
> System.out.println("I'm in Struts 1 Action ");
> MyForm form1=(MyForm)form;
> System.out.println(form1.getUserId());
> return mapping.findForward("success");
> }
> }
> -----------------------
> struts.xml
> ------------------------
> <package name="udaykumar" namespace="/html2" extends="struts-default">
> <action name="login">
> <result>/pages/strutslogin.jsp</result>
> </action>
> </package>
> <package name="struts" namespace="/struts1" extends="struts1-default">
> <action name="logon" class="org.apache.struts2.s1.Struts1Action">
>
> <interceptor-ref name="scopedModelDriven">
> <param name="className">com.MyForm</param>
> <param name="name">form1</param>
> <param name="scope">session</param>
> </interceptor-ref>
> <interceptor-ref name="struts1-default"/>
> <param name="className">com.MyAction</param>
> <result name="success">/pages/strutsResult.jsp</result>
> </action>
> </package>
> Please provide me the solution. Give me a example for this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.