如何从Dao类获取数据并设置控制器类

时间:2019-06-03 08:38:45

标签: java spring-mvc

如何使用控制器中的list>从Dao类中获取数据

<!DOCTYPE html>

<html lang="es">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <title>Aplicacion de autos</title>

</head>

<body>

    <div class="container-fluid">

        <div class="row">

            <div class="col-md-6"></div>

                <form action="{{route('cars.crear')}}" method="post">

                   @csrf

                    <div class="row form-group">

                        <div class="col-md-12">

                            <label for="">Introducir:</label>

                            <input type="text" name="introducir" class="form-control" required>

                        </div>

                    </div>

                    <div class="row form-group">

                        <div class="col-md-12">

                            <label for="">Modelo:</label>

                            <input type="text" name="modelo" class="form-control" required>

                        </div>
                    </div>

                    <div class="row form-group">

                        <div class="col-md-12">

                            <label for="">Producido_en:</label>

                            <input type="date" name="producido-en" class="form-control" required>

                        </div>

                    </div>

                    <div class="row form-group">

                        <div class="col-md-12">

                            <button type="submit" class="btm btm-success w-50 float-right">Crear</button>

                        </div>

                    </div>

                </form>

            </div> 

            <div class="col-md-6">

                <table class="table table-striped table-hover">

                    <tr>

                        <th>Introducir</th>

                        <th>Modelo</th>

                        <th>Producido_en</th>

                    </tr>

                    <tr>

                        <td></td>

                        <td></td>

                        <td></td>

                </table>     

            </div> 

    </div>  

</body>

</html>

RegisterDao

@RequestMapping(value = {"/log"}, method=RequestMethod.POST)
@ResponseBody
public String login(HttpSession session, String username, String password) throws Exception {

    Register r =new Register(username, password);
    List<Map<String,Object>> list=rdao.GetUserData(r);
    Member member=list.get(1).get("username").equals("password");

    if(member !=null) 
    {
    session.setAttribute("MEMBER", member); 
     return "taskform";
    }
    else
    {
        throw new Exception("invalid user name or password");
    }
    return "loginup";
}   

你好,我以寄存器形式向控制器获取数据,但没有获取数据

0 个答案:

没有答案