RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

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

Vitaly M.'s questions

Martin Hope
Vitaly M.
Asked: 2020-11-12 18:24:27 +0000 UTC

spring boot 多威胁

  • 0

我的应用程序中有一个类。

public Robot implements Callable<String> {
@Override
    public String call() {
        synchronized (monitor) {
            while (true) {
                /// doing somthing
                monitor.wait(15000L)
            }
        }
    }
}

然后有一个启动 Robot 对象的服务类

List<Robot> robots = <10000 роботов>
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setMaxPoolSize(robots.size());
threadPoolTaskExecutor.setCorePoolSize(robots.size());
threadPoolTaskExecutor.initialize();

for (Robot robot : robots) {
    try {
         Future<String> result = threadPoolTaskExecutor.submit(robot);
    } catch (Exception e) {
         log.warn("", e);
    }
}

如果我像这样运行它,我会得到

[70,174s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

关键是每个机器人每 15 秒执行一次动作并入睡。

动作本身只需要几分之一秒。

有一个想法是采用一个线程池,并在一个循环中,每 15 秒一次,通过它运行一个机器人列表。但是我有一个条件,即机器人执行第一个动作时有随机延迟,所有其他重复动作在前一个动作之后的间隔约为 15 秒。而且我不知道该怎么做...

многопоточность
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-07-30 01:19:24 +0000 UTC

如何将 JSP 页面格式化到左侧?

  • 0

这是我的页面。它将中心的内容对齐到左侧,我希望内容的放置和对齐方式<div class="container h-100 text-left">...</div>在浏览器的左侧......

我该怎么做?

<html>
<head>

    <%--   For Bootstrap--%>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <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">
    <%--  End for bootstrap  --%>

    <title>Hellow World</title>
</head>

<body>
<div class="container h-100 text-left">
    <div class="py-5 text-left">
        <h2>${message}</h2>
        <p class="lead">
            <c:out value="${message.toString()}"/>
        </p>
    </div>
    <div class="row">
        <form id="settingsForm" method="post" action="update">
            <div class="order-md-1" id="settingsDiv">
...
            </div>
        </form>
    </div>
</div>

<%--For bootstrap--%>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
        crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
        crossorigin="anonymous"></script>
<%--end for bootstrap--%>
</body>
</html>
php
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-06-13 16:47:14 +0000 UTC

EventPublisher 在访问 ArrayList 时抛出 java.util.ConcurrentModificationException

  • 1

有一个类:

@Component
public class EventPublisherImpl implements EventPublisher {

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    private List<EventListener> listeners = new ArrayList<>();

    @Override
    public void addListener(EventListener toAdd) {
        listeners.add(toAdd);
    }

    @Override
    public void removeListener(EventListener toRemove) {
        listeners.remove(toRemove);
    }

    public void publicEvent(AmiObject amiObject) {
        if (listeners != null && !listeners.isEmpty()) {
            Iterator<EventListener> iterator = listeners.iterator();
            while (iterator.hasNext())
                synchronized (iterator) {
                    EventListener eventListener = iterator.next();
                    if (eventListener != null) {
                        eventListener.publicEvent(amiObject);
                    }
                }
        }
    }
}

EventListeners 从不同的线程添加到它。

因此,在启动时,会出现错误:

Exception in thread "Thread-1" java.util.ConcurrentModificationException
    at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042)
    at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996)
    at ...EventPublisherImpl.publicEvent(EventPublisherImpl.java:34)
    at ...AmiObjectParserImpl.parseStr(AmiObjectParserImpl.java:45)
    at ...ConnectorImpl.listenSocket(ConnectorImpl.java:214)
    at ...ConnectorImpl.run(ConnectorImpl.java:92)
    at java.base/java.lang.Thread.run(Thread.java:834)

并指向线

EventListener eventListener = iterator.next();
java
  • 2 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-05-25 16:55:51 +0000 UTC

spring-webmvc.xml 配置

  • 0

帮助配置 Spring。

控制器

@Controller
@RequestMapping("/*")
public class IndexController {

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    @RequestMapping(method = RequestMethod.GET)
    public String printHello(HttpServletRequest request, Model model) {
...

存储库

@Repository
public class JpaRepositoryImpl implements JpaRepository {

    @PersistenceContext
    private EntityManager emf; // Для внедрения EntityManager
...

好吧,一堆其他必要的类

在 spring-db.xml 中连接的存储库

...
<context:component-scan base-package="ru.bityard.bitrix24.serverAuth.repository"/>
...

spring-mvc.xml 中连接的控制器和服务

...

    <context:component-scan base-package="ru.bityard.bitrix24.serverAuth.**.web"/>
    <context:component-scan base-package="ru.bityard.bitrix24.serverAuth.**.service"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
...

我在 spring-app.xml 中收集所有其他 bean

这就是我试图在 web.xml 中组合的所有内容

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <display-name>Spring MVC Application</display-name>

    <context-param>
        <param-name>contextClass</param-name>
        <param-value>
            org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        </param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:spring-app.xml
            classpath:spring-db.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>index</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath:spring-mvc.xml
            </param-value>
        </init-param>
        <init-param>
            <param-name>throwExceptionIfNoHandlerFound</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>contextClass</param-name>
            <param-value>
                org.springframework.web.context.support.AnnotationConfigWebApplicationContext
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>index</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

我收到一个错误:

2019-05-25 11:48:00 DEBUG http-nio-8080-exec-4:DispatcherServlet.java:doService:891 - DispatcherServlet with name 'index' processing GET request for [/index.php]
2019-05-25 11:48:00 DEBUG http-nio-8080-exec-4:AbstractHandlerMethodMapping.java:getHandlerInternal:312 - Looking up handler method for path /index.php
2019-05-25 11:48:00 DEBUG http-nio-8080-exec-4:AbstractHandlerMethodMapping.java:getHandlerInternal:322 - Did not find handler method for [/index.php]
2019-05-25 11:48:00 WARN  http-nio-8080-exec-4:DispatcherServlet.java:noHandlerFound:1205 - No mapping found for HTTP request with URI [/index.php] in DispatcherServlet with name 'index'
2019-05-25 11:48:00 DEBUG http-nio-8080-exec-4:FrameworkServlet.java:processRequest:1000 - Successfully completed request

我的配置错误在哪里?

java
  • 2 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-04-24 16:42:37 +0000 UTC

如何通过 Maven 拉取自己的包?

  • 0

我写了一个模块。在 pom.xml 中,我使用 spring-boot 设置来构建项目:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.0.4.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <mainClass>ru.Main</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
            </resource>
        </resources>

    </build>

在 IDEA 中执行 install jar 后,昵称会进入本地 maven 存储库 .m2/repository/

之后,我在 pom.xml 的新项目中向我的包添加依赖项:

        <dependency>
            <groupId>ru.bityard.asterisk</groupId>
            <artifactId>ami</artifactId>
            <version>1.0.0</version>
        </dependency>

IDEA 看到并加载它。

现在我正在尝试从这个包中创建一个类的实例,但它不起作用...... IDEA 本身要求将导入添加到包中?我同意,没有任何反应...

想法截图

我试图用我的双手书写路径

import ru.bityard.asterisk

但IDEA没有看到它......

我看到在maven加载的所有包中,classpath都是从包的根目录开始的,例如:

org/springframework/... 

在我的包裹中,路径开始

BOOT-INF/classes/ru/...

也许这就是问题所在?帮助我理解。

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-04-05 18:39:21 +0000 UTC

Java反射私有方法

  • 1
private Map<String, Set<DeliveryOrder>> getOrdersMap(DeliveryOrder[] deliveryOrders) {
...
}

在另一堂课我做反思

DeliveryOrder[] deliveryOrders = {do1,do4,do3,do2};

try {
    method = reCallReportController.getClass().getDeclaredMethod("getOrdersMap", DeliveryOrder[].class);
    method.setAccessible(true);
    deliveryOrderMap = (Map<String, Set<DeliveryOrder>>) method.invoke(reCallReportController,deliveryOrders);
} catch (Exception e) {
    e.printStackTrace();
}

我收到一个错误:

java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at TestReCallReportController.testGetOrdersMap(TestReCallReportController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

为什么???

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-11-07 18:42:44 +0000 UTC

正则表达式。如何替换除模板之外的所有内容?

  • 2
String line = "101@ext-local       : SIP/101,CustomPresen  State:Idle            Presence:not_set         Watchers  0";
System.out.println(line.replaceAll("^(\\w+/\\d+)","")); <- не работает

我需要喝一口/101

如何?

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-09-27 15:22:25 +0000 UTC

如何在 Java 中正确处理传入的 JSON?

  • 2

如何提出请求并处理它们 - 我想通了。

以及如何配置应用程序以侦听特定端口,我想不通。

特别是,我需要从 Bitrix24 制作一个传入的 webhook 处理程序。那些。

Bitrix 手册说:

укажите url вашего обработчика в настройках исходящего webhook
https://your_server/your_webhook_script.php


код обработчика

<?php

/*

Битрикс24 передает в обработчик $_REQUEST с данными:

array(
 'PHONE_NUMBER' => '555666777', //номер, на который звонит пользователь Битрикс24
 'USER_ID' => '1', //пользователь, который звонит из интерфейса Битрикс24
 'CRM_ENTITY_TYPE' => 'LEAD', //тип объекта CRM, из карточки которого звонит пользователь Битрикс24
 'CRM_ENTITY_ID' => '248' //ID объекта CRM, из карточки которого звонит пользователь Битрикс24
)
*/
java
  • 2 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-09-25 18:47:59 +0000 UTC

Pojo 对象字段名称

  • 0

为什么objectMapper它看不到对象的字段设置器Pojo?

班级User

    public class User {
        private String ID;
        private boolean ACTIVE;
        private String UF_PHONE_INNER;

        public String getID() {
            return ID;
        }

        public void setID(String ID) {
            this.ID = ID;
        }
... и т.д.

班级Users

public class Users {
    private User[] result;

    public User[] getUsers() {
        return result;
    }

    public void setResult(User[] result) {
        this.result = result;
    }
и т.д....

拆解JSON

log.debug("jsonString is {}",jsonString);
users.setResult(objectMapper.readValue(jsonString, Users.class).getUsers());

我得到:

DEBUG log:71 - jsonString is {"result":[{"ID":"1","ACTIVE":true,...
WARN  log:81 - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ID" (class ru.bityard.bitrix24.User), not marked as ignorable (3 known properties: "id", "active", "uf_PHONE_INNER"])

我不明白为什么他看到id而不是ID???我的印象是解析器将字段ID视为对象......

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-08-20 23:43:10 +0000 UTC

Logger slf4j - 如何在启动时设置日志记录级别?

  • 0

大家好!

我在 spring-app.xml 中设置了日志 bean:

<bean id="logger" scope="prototype" class="org.slf4j.LoggerFactory" factory-method="getLogger">
        <constructor-arg name="name" value="log"/>
</bean>

此外,我在类中放置了各种情况所需的日志记录级别:

@Autowired
private Logger log;

log.warn(...);
log.info(...);
log.debug(...);

我有一个在启动时加载到程序中的 config.conf 文本文件:

Properties properties = new Properties();
properties.load(this.getClass().getClassLoader().getResourceAsStream(configFile));

如何设置日志记录级别(信息、调试),比如控制台,我可以在 config.conf 文件中指定?

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-08-09 17:12:31 +0000 UTC

找不到 XML 模式的 Spring NamespaceHandler

  • 0

一旦我释放 jar 并尝试在 Idea 之外运行它,就会出现错误:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [spring/spring-app.xml]

这是开始类:package ru.start;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@Configuration
public class Start {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("spring/spring-app.xml");
//        ((ClassPathXmlApplicationContext) (ctx)).close();
    }
}

这是spring-app.xml

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

    <bean id="logger" scope="prototype" class="org.slf4j.LoggerFactory" factory-method="getLogger">
        <constructor-arg name="name" value="log" />
    </bean>

    <context:component-scan base-package="ru.iiko"/>

    <task:annotation-driven executor="executor" scheduler="scheduler"/>
    <task:executor id="executor" pool-size="5"/>
    <task:scheduler id="scheduler" pool-size="10"/>
</beans>

也许我没有在 pom.xml 中提取一些东西?这是我对 spring 的依赖项:

<!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-framework-bom</artifactId>
            <version>${spring.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>

帮助我理解为什么...

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-07-30 15:24:24 +0000 UTC

JSP 动态变量名

  • 0

我的任务是在页面更新时将数据保存在页面上。

那些。我在 JSP 中有呈现复选框的代码。我不知道他们的名字和号码。

<c:forEach items="${trunks}" var="trunk">
 <jsp:useBean id="trunk" scope="page" type="ru.bityard.pojo.Trunk"/>
  <tr>
   <td style="padding: 5px; vertical-align: middle">
    <input type="checkbox" 
           name="${trunk.name}" 
           value="${trunk.name}" 
           <%= ("on".equals(checkbox) ? "checked" : "") %>
    />
    ${trunk.name}
   </td>
  </tr>
</c:forEach>

有一个控制器接受 PostMapping ,做它需要的事情,包括将所有参数传递给 GetMapping。

@PostMapping
 public String call(HttpServletRequest request, Model model) {
  ...
        // Вытаскиваю все параметры, со всеми значениями
        Map<String, String[]> parameters = request.getParameterMap();

        // Записываю все параметры в модель и передаю на GetMapping
        model.addAllAttributes(parameters);

        return "redirect:/missedCalls";
    }

@GetMapping
    public String create(HttpServletRequest request, Model model) {
        ...
        model.addAllAttributes(request.getParameterMap());
        return "missedCalls";
    }

在这里我不知道如何检查变量是否具有“on”值,然后我们放置“checked”标志。由于我的变量名是动态设置的=${trunk.name}

我不知道如何将(checkbox)变量名传递给这个表达式而不是存根:

<%= ("on".equals(checkbox) ? "checked" : "") %>

jsp
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-07-27 21:59:12 +0000 UTC

JSP如何按条件更改INPUT字段的必需属性?

  • 2

我有一个带有 required=true 选项的输入字段和一个提交按钮。我希望输入字段在单击提交时将所需选项设置为 false。

<table style="width: 100%">
 <tr>
  <td>
   <input class="form-control col-5" name="agent" id="agent" value="${agent}" placeholder="<spring:message code="report.missedCalls.agent"/>" required="true">
  </td>
  <td align="right">
   <button id="refresh" type="submit" class="btn btn-lg small btn-primary" onclick=checkform()>
    <spring:message code="report.refresh"/>
   </button>
  </td>
 </tr>
</table>

<script>
    function checkform()
    {
        $("#agent").required=false;
    }
</script>

但有些东西对我不起作用,需要禁用。

请帮帮我

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-05-04 22:56:15 +0000 UTC

jdbcTemplate.query(query, ROW_MAPPER) 创建空对象

  • 1

一个东西:

public class MissedCall {

    private Timestamp dateTime;
    private String callerId;    
    private Long duration;       

    public MissedCall(Timestamp dateTime, String callerId, long duration) {
        this.dateTime = dateTime
        this.callerId = callerId;
        this.duration = duration;
    }

执行请求的方法:

public class JdbcMissedCallRepositoryImpl implements JdbcMissedCallRepository {
    ...

    private static final RowMapper<MissedCall> ROW_MAPPER = BeanPropertyRowMapper.newInstance(MissedCall.class);
    ...
    public List<MissedCall> getForLastDays() {
    ...
    List<MissedCall> missedCalls = jdbcTemplate.query(query, ROW_MAPPER);
    ...
    }

结果,在列表中我得到一个空的 MissedCall 对象......

如果查询是手动执行的,那么结果是:

+---------------------+-------------+------+
| atm                 | asrc        | adur |
+---------------------+-------------+------+
| 2018-05-02 19:46:21 | 89181112233 |    4 |
+---------------------+-------------+------+
1 row in set (0.00 sec)

他需要什么来匹配这些字段?

java
  • 1 个回答
  • 10 Views
Martin Hope
Vitaly M.
Asked: 2020-02-04 23:43:29 +0000 UTC

JavaFX。文字+超链接

  • 1

怎么做:“纯文本 -链接”

我愿意:

Hyperlink hyperlink = new Hyperlink("Ссылка");    
Label label = new Label("Простой текст - ");
Pane pane = new Pane();
pane.getChildren().addAll(label,hyperlink);
bottomBorderPane.setCenter(pane);

但是最后超链接和标签是在一个上面显示的,而不是在bottomBorderPane的中心,而是在左边...

javafx
  • 2 个回答
  • 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