转自:http://blog.csdn.net/fangzhongwei/article/details/5039087
1. 在Struts-config-ext.xml文件中,建立转向静态页面register.jsp的配置如下:
<forward className="com.ibm.commerce.struts.ECActionForward" name="IndexRegister" path="/ConsumerDirect/register.jsp"/>
<action path="/IndexRegister" type="com.ibm.commerce.struts.BaseAction"/>
这里因为没有Command处理,所以没有parameter属性的配置。
register.jsp页面代码如下:
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>注册页面</title>
</head>
<body bgcolor="pink">
<center>
<h3 style="font-size:20pt">注册信息</h3>
<form name="reg" method="post" action="register_gentlemen">
<table width="300" border="1" cellspacing="0" cellpadding="2">
<tr>
<td align="right" width="30%" height="25">姓名:</td>
<td align="left" width="70%" height="25" > <input type="text" id="user_id" name="username" size="23" maxlength="15" style="left-margin:5"></td>
</tr>
<tr>
<td align="right" width="30%" height="25">密码:</td>
<td align="left" width="70%" height="25" > <input type="password" id="password_id" name="password_name" size="25" maxlength="15" style="left-margin:5px"></td>
</tr>
<tr>
<td align="right" width="30%" height="25">重复密码:</td>
<td align="left" width="70%" height="25" > <input type="password" id="repassword_id" name="repassword_name" size="25" maxlength="15" style="left-margin:5px"></td>
</tr>
</table>
<table width="300" border="0">
<tr>
<td colspan="2" height="5">
</td>
</tr>
<tr>
<td colspan="2" height="25" width="100%" align="right" valign="bottom">
<input type="submit" name="sub_name" value="确 认"> <input type="reset" name="reset_name" value="取 消">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
2. 对写好的register.jsp页面进行access controll注册。注册代码放在F:/WCToolkitEE60/xml/policies/xml/IndexRegisterPolicies.xml中,配置如下:
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE Policies SYSTEM "../dtd/accesscontrolpolicies.dtd">
<Policies>
<Action Name="IndexRegister" CommandName="IndexRegister"></Action>
<ActionGroup Name="AllSiteUsersViews" OwnerID="RootOrganization">
<ActionGroupAction Name="IndexRegister"/>
</ActionGroup>
</Policies>
3. cmd进入控制台,运行acpload IndexRegisterPolicies.xml (注意一定要停止服务)。
4. 注册信息要提交到Command进行处理,首先定义一个Command接口。如下:
package com.ibm.commerce.test.commands;
import com.ibm.commerce.command.ControllerCommand;
public interface RegisterCmd extends ControllerCommand {
static final String defaultCommandClassName="com.ibm.commerce.test.commands.RegisterCmdImpl";
}
5. 定义Command实现类,如下:
package com.ibm.commerce.test.commands;
import com.ibm.commerce.command.ControllerCommandImpl;
import com.ibm.commerce.datatype.TypedProperty;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.server.ECConstants;
public class RegisterCmdImpl extends ControllerCommandImpl implements
RegisterCmd {
public void performExecute()throws ECException{
super.performExecute();
TypedProperty tp = this.getRequestProperties();
String username = tp.getString("username");
String password = tp.getString("password_name");
String repassword = tp.getString("repassword_name");
TypedProperty response = new TypedProperty();
response.put("username", username);
response.put("password", password);
response.put("repassword", repassword);
response.put(ECConstants.EC_VIEWTASKNAME, "welcome_gentlemen");
this.setResponseProperties(response);
}
}
6. 在数据库中注册Command,运行如下:
insert into CMDREG (STOREENT_ID, INTERFACENAME, DESCRIPTION, CLASSNAME, TARGET) values (CD_storeent_ID,'com.ibm.commerce.test.commands.RegisterCmd ', '', 'com.ibm.commerce.test.commands.RegisterCmdImpl','Local');
7. 配置Command的访问权限:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE Policies SYSTEM "../dtd/accesscontrolpolicies.dtd">
<Policies>
<Action Name="ExecuteCommand" CommandName="Execute"></Action>
<ResourceCategory Name="com.ibm.commerce.test.commands.RegisterCmdResourceCategory" ResourceBeanClass="com.ibm.commerce.test.commands.RegisterCmd">
<ResourceAction Name="ExecuteCommand"/>
</ResourceCategory>
<ResourceGroup Name="AllSiteUserCmdResourceGroup" OwnerID="RootOrganization">
<ResourceGroupResource Name="com.ibm.commerce.test.commands.RegisterCmdResourceCategory" />
</ResourceGroup>
</Policies>
8.在struts-config.ext.xml中配置Command的action,这里没有forward的配置,定向在Command的方法中设置,如下:
<action path="/register_gentlemen" type="com.ibm.commerce.struts.BaseAction" parameter="com.ibm.commerce.test.commands.RegisterCmd"></action>
9.配置最后的welcome页面:
<action path="/welcome_gentlemen" type="com.ibm.commerce.struts.BaseAction"></action>
<forward name="welcome_gentlemen" path="/ConsumerDirect/welcome.jsp" className="com.ibm.commerce.struts.ECActionForward"></forward>
页面的代码如下:
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>欢迎页面</title>
</head>
<body bgcolor="pink">
<center>
<h3>welcome!</h3>
username: <c:out value="${username}"/><br>
password: <c:out value="${password}"/><br>
repassword: <c:out value="${repassword}"/>
</center>
</body>
</html>
10. 最后对页面的access controll进行注册
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE Policies SYSTEM "../dtd/accesscontrolpolicies.dtd">
<Policies>
<Action Name="welcome_gentlemen" CommandName="welcome_gentlemen"></Action>
<ActionGroup Name="AllSiteUsersViews" OwnerID="RootOrganization">
<ActionGroupAction Name="welcome_gentlemen"/>
</ActionGroup>
</Policies>
最后运行即可:http://localhost/webapp/wcs/stores/servlet/IndexRegister
Websphere Commerce Suite 架构开发一个模块的流程
猜你喜欢
转载自ihyperwin.iteye.com/blog/1705588
今日推荐
周排行