为了账号安全,请及时绑定邮箱和手机立即绑定

好想没有这个标签啊


package com.ls.action;


import com.ls.entity.User;

import com.opensymphony.xwork2.ActionSupport;

import com.opensymphony.xwork2.ModelDriven;


public class LoginAction extends ActionSupport implements ModelDriven<User>{


private static final long serialVersionUID = 2420947456421303802L;

private User user =new User();

public String login() {

if(user.getUsername()==null || " ".equals(user.getUsername())){

this.addFieldError("username", "姓名不能为空");

return INPUT;

}

System.out.println(user.getUsername());

System.out.println(user.getBookList().get(0).getUsername());

System.out.println(user.getBookList().get(1).getUsername());

return SUCCESS;

}


@Override

public User getModel() {

// TODO Auto-generated method stub

return user;

}




}


正在回答

3 回答

http://img1.sycdn.imooc.com//59cd2eae0001c0c819200944.jpg莫名哦

0 回复 有任何疑惑可以回复我~

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>

<package name="default" namespace="/"  extends="struts-default"> 

<action name="LoginAction"  class="com.ls.action.LoginAction"  method="login">

<result >/success.jsp</result>

<result name="input">/index.jsp</result>

</action>

</package>

</struts>    


0 回复 有任何疑惑可以回复我~

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@taglib prefix="s" uri="/struts-tags" %>

<%

String path = request.getContextPath();

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

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

  </head>

  

  <body>

    <form action="LoginAction.action" method="post" >

    <input type="text" name="username"/><s:fielderror name="username"></s:fielderror><br/>

    <input type="text" name="password"/><br/>

    <input type="text" name="bookList[0].username"/><br/>

    <input type="text" name="bookList[1].username"/><br/>

    <input type="text" name="age"/><br>

    <input type="submit" value="提交"/><br/>

    </form>

  </body>

</html>


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

好想没有这个标签啊

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信