页面用的jsp 用的struts2框架
1. jsp写了两个form,但提交的时候,两个一齐提交到同一个Action里了,怎么去Action里定位是提交到某个方法呢。
2. Action用的注解形式,如果可以映射的话,Action的映射怎么配?
3. 这个例子,基于struts2标签的 jsp 页面怎么做?希望高人给个例子,别拷贝网站上的
谢谢!
1. jsp写了两个form,但提交的时候,两个一齐提交到同一个Action里了,怎么去Action里定位是提交到某个方法呢。
2. Action用的注解形式,如果可以映射的话,Action的映射怎么配?
3. 这个例子,基于struts2标签的 jsp 页面怎么做?希望高人给个例子,别拷贝网站上的
谢谢!
<result type="redirectAction">${nextDispose}</result>
<result name="input" type="dispatcher">/login.jsp</result>
</action>
<action name="register" class="cn.jbit.houserent.action.UserAction" method="register">
<result name="success" type="dispatcher">/result.jsp</result>
<result name="error" type="dispatcher">/result.jsp</result>
</action>
如上我将登录和注册都写在了UserAction中通过method属性指定要调用的方法。
登录页面的表单访问login.action
注册页面的表单访问register.action
http://topic.csdn.net/u/20100906/16/aaa26f8d-c983-4655-9560-c4869addcbc9.html
@Component
@Scope("prototype")
@Namespace("/")
public class UserAction extends BaseAction
{ /**
*
*/
private static final long serialVersionUID = 1L; private static final Logger LOGGER = Logger.getLogger(UserAction.class); private String account; private String passwd; private String vcode; @Action(value = "/login", results = { @Result(name = "login", location = "login.jsp") })
public String login()
{
LOGGER.debug("Login");
return "login";
} @Action(value = "/doLogin")
public void doLogin()
{
// TODO 这里需要操作数据库,暂时只是为了搭建框架使用
ProcessResult<JSON> processResult = new ProcessResult<JSON>();
String vcode = (String) session.getAttribute("VCODE");
if (!this.vcode.equals(vcode))
{
processResult.setSuccess(false);
processResult.setMessage("验证码错误!");
sendJson(processResult.toJSON());
return;
}
processResult.setSuccess(true);
sendJson(processResult.toJSON());
return;
}看看这个适不适合你