RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-319208

Teemitze's questions

Martin Hope
Teemitze
Asked: 2022-04-10 15:16:24 +0000 UTC

为什么双==双假?

  • 6

这是工作代码。我知道比较equals更好,但是为什么在创建具有相同值的新Double时,它指的是内存中的不同位置,而Long却没有。

public class Main {
    public static void main(String[] args) {
        Long firstLong = 1L;
        Long secondLong = 1L;

        Double firstDouble = 1.0;
        Double secondDouble = 1.0;


        System.out.println(firstLong == secondLong);
        System.out.println(firstDouble == secondDouble);
    }
}
java
  • 2 个回答
  • 10 Views
Martin Hope
Teemitze
Asked: 2020-06-18 12:30:51 +0000 UTC

图的拓扑排序

  • -1

我不明白为什么图表是这样排序的。翻译是正确的,没有错误。

一个任务

回答

алгоритм
  • 1 个回答
  • 10 Views
Martin Hope
Teemitze
Asked: 2020-05-22 18:11:41 +0000 UTC

如何获取默认值?

  • 0

如何获得默认值(28)?这是 github 上更完整的代码https://github.com/Teemitze/test

    package ru.otus.spring01.dao;

    import ru.otus.spring01.domain.Person;

    public class PersonDaoSimple implements PersonDao {

        public Person findByName(String name) {
            return new Person(name, 18);
        }

        public void setDefaultAge(String defaultAge) {
        }
    }

春天.xml


        <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns="http://www.springframework.org/schema/beans"
               xsi:schemaLocation="http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd">


            <bean id="personDao" class="ru.otus.spring01.dao.PersonDaoSimple">
                <property name="defaultAge" value="28"/>
            </bean>

            <bean id="personService" class="ru.otus.spring01.service.PersonServiceImpl">
                <constructor-arg name="dao" ref="personDao"/>
            </bean>

    </beans>

java
  • 1 个回答
  • 10 Views
Martin Hope
Teemitze
Asked: 2020-05-03 17:06:18 +0000 UTC

重定向并保留标题

  • 0
    post("/authentication", (req, res) -> {
        Authentication authentication = new Authentication();
        if (authentication.validate(req.headers("login"), req.headers("password"))) { // Проверяем логин и пароль
            UserService userService = new UserService();
            int id = userService.findByLogin(req.headers("login")).getId(); // Получаем id пользователя
            res.header("id", String.valueOf(id)); // Передаём в header id
            res.redirect("/myAnimals"); // Делаем редирект на страницу "/myAnimals"
        }
        return "NO";
    });

        get("/myAnimals", (req, res) -> {
        int id = Integer.parseInt(req.headers("id")); // Пытаемся получить переданный id с запроса post "/authentication" 
        return animalService.userAnimalsJson(id); // Возвращаем всех животных пользователя
    });

问题是我收到 500 错误。如果我也这样做,但我通过 cookie 传递 id,那么一切都很好。

日志中没有任何内容:

мая 03, 2019 12:51:56 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
мая 03, 2019 12:51:56 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.2.Final}
мая 03, 2019 12:51:56 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
мая 03, 2019 12:51:56 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
мая 03, 2019 12:51:56 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: hibernate.cfg.xml
мая 03, 2019 12:51:56 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: hibernate.cfg.xml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/home/teemitze/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
мая 03, 2019 12:51:56 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
Hibernate Configuration loaded
Hibernate serviceRegistry created
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/soaweb]
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {password=****, user=root}
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
мая 03, 2019 12:51:56 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
мая 03, 2019 12:51:56 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
мая 03, 2019 12:51:56 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
мая 03, 2019 12:51:56 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select this_.id as id1_1_0_, this_.login as login2_1_0_, this_.password as password3_1_0_ from users this_ where this_.login like ?
Hibernate: select this_.id as id1_1_0_, this_.login as login2_1_0_, this_.password as password3_1_0_ from users this_ where this_.login like ?

页面出现以下错误

<html>
<body>
    <h2>500 Internal Server Error</h2>
</body>

java
  • 1 个回答
  • 10 Views
Martin Hope
Teemitze
Asked: 2020-12-12 14:54:06 +0000 UTC

Java中的DTO是什么?

  • 10

您能否使用简单的 JAVA 代码示例来解释 DTO 是什么?为什么需要这个?

这段代码会是 DTO 吗?有两个类客户和银行

顾客

    import java.sql.Date;

class Customer {
    private String first_name;
    private String last_name;
    private String gedner;
    private Date age;
    private String address;


    Customer(String first_name, String last_name, String gedner, Date age, String address) {
        this.first_name = first_name;
        this.last_name = last_name;
        this.gedner = gedner;
        this.age = age;
        this.address = address;
    }

    public String getLast_name() {
        return last_name;
    }

    public String getFirst_name() {
        return first_name;
    }

    public String getGedner() {
        return gedner;
    }

    public Date getAge() {
        return age;
    }

    public String getAddress() {
        return address;
    }
}

银行

import java.sql.*;
import java.util.Scanner;


public class Bank {
    private static final String URL = "jdbc:mysql://localhost/bank?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
    private static final String USER = "root";
    private static final String PASSWORD = "root";

    Connection connection = null;
    PreparedStatement preparedStatement = null;
    Scanner in = new Scanner(System.in);

    public void connect() {
        try {
            connection = DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    Customer readCustomer() {
        Customer customer = null;
        try {
            preparedStatement = connection.prepareStatement("SELECT * FROM customers WHERE id_customer = ?");
            System.out.print("Введите id пользователя: ");
            preparedStatement.setInt(1, Integer.parseInt(in.next()));
            preparedStatement.execute();
            ResultSet rs = preparedStatement.executeQuery();
            String first_name = rs.getString("first_name");
            String last_name = rs.getString("last_name");
            String gender = rs.getString("gender");
            Date age = rs.getDate("age");
            String address = rs.getString("address");
            customer = new Customer(first_name, last_name, gender, age, address);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                preparedStatement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return customer;
    }
}

在 read 方法中,我将 ResultSet 变成了一个客户对象。这是DTO吗?

java
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5