小编Jac*_*ack的帖子

为什么我收到响应代码:非HTTP响应代码:java.net.SocketException?

我正在尝试使用JMeter将请求发送到我在localhost上运行的应用程序,但由于java.net.SocketException,许多请求都失败了.我没有在控制台中看到任何异常.

我读了这些问题1问题2,但没有多大帮助.

我的代码如下:

 try {
        return myService.findItems(group);

    } catch (NullPointerException n) {
        n.printStackTrace();
    } catch (HibernateException h) {
        h.printStackTrace();
    } catch (IOException i) {
        i.printStackTrace();
    }
    return null;
Run Code Online (Sandbox Code Playgroud)

知识库

  public LinkedHashMap findItems(String group) throws NullPointerException, HibernateException, IOException {
        Session session = sessionFactory.getCurrentSession();
                 ..... //request is sent to database

        return items;
    }
Run Code Online (Sandbox Code Playgroud)

我的JMeter配置的屏幕截图

在此输入图像描述

在此输入图像描述

在此输入图像描述

在此输入图像描述

java performance spring-mvc jmeter performance-testing

4
推荐指数
1
解决办法
2万
查看次数

如何保护注册页面免遭多个恶意请求?

我允许用户使用注册表格在我的网站上注册。提交表单后,将生成令牌并将其通过电子邮件发送给用户,他们需要单击令牌链接以激活其帐户。

我的问题是,如果我这样做了,恶意代码是否仍然可以向我的网站发送多封电子邮件进行注册,我应该使用验证码来保护网站还是有其他方法?

java captcha spring-security

3
推荐指数
1
解决办法
1056
查看次数

无法解组SOAP响应

我可以发送请求并收到响应,但我无法解析响应.它返回以下错误:

Local Name:Body
error is here
java.lang.NullPointerException
    at com.ticketmaster.ticketmaster.TicketMaster.Search(TicketMaster.java:119)
    at com.ticketmaster.ticketmaster.App.main(App.java:12)
Run Code Online (Sandbox Code Playgroud)

    SOAPMessage response
            = connection.call(message, endpoint);

    connection.close();
        SOAPMessage sm = response;
        SOAPBody sb = response.getSOAPBody();
        System.err.println("Node Name:" + sb.getNodeName());  //return nothing
        System.err.println("Local Name:" + sb.getLocalName());  //return Local Name:Body

        DOMSource source = new DOMSource(sb);
        results = (FindEventsResponse) JAXB.unmarshal(source, FindEventsResponse.class);
        System.err.println("Results size: " + this.results.returnTag.results.item.get(0).getName());

} catch (Exception ex) {
    System.err.println("error is here");
    ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

响应:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
                   xmlns:ns1="http://ticketmaster.productserve.com/v2/soap.php" 
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <ns1:findEventsResponse>
            <return xsi:type="ns1:Response">
                <details …
Run Code Online (Sandbox Code Playgroud)

java soap jaxb unmarshalling stringreader

3
推荐指数
1
解决办法
9174
查看次数

如何防止div溢出到另一个div上

我对以下标题的唯一问题是,通过更改屏幕尺寸,这两个按钮与搜索按钮重叠。我需要它们留在原处,并且在小屏幕中没有足够的空间将搜索框和按钮放在水平线上。两个按钮会跳起来。就在三个小图像的下方。

我删除了一些与问题无关的CSS样式以简化代码。

演示版

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">


<link rel="stylesheet"
    href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet"
    href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.2.1/bootstrap-social.css">

<style>

html, body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
}

.show-xs {
    display: none;
}

@media ( max-width : 480px) {
    .top-center {
        width: 100%;
    }
    .top-right {
        padding-bottom: 4px;
    }

    #logo {
        width: 120%;
    }
    .btn-search {
        float: right;
    }
    .login {
        margin-left: 10px;
        margin-right: -23px;
    }
    .show-xs {
        display: block; …
Run Code Online (Sandbox Code Playgroud)

css twitter-bootstrap twitter-bootstrap-3

3
推荐指数
1
解决办法
8768
查看次数

如何将所选复选框的值传递给javascript函数?

我需要将所选复选框的值传递给javascript方法,但它不会检测复选框.

<form name="cat" method="POST" action="myaction">     
    <c:forEach items="${items}" var="item">
        <input type="checkbox" id="pro" name="pro" value="${item.id}"/>
    </c:forEach>
    ...
    <input type="button" value="getItem" onclick="getItem(this.form)"/> 
 </form>
Run Code Online (Sandbox Code Playgroud)

使用Javascript

function getItem(frm) {

    alert("size:" + frm.pro.length);   <<< it returns size:unidentified
    var values = "";
    for (var i = 0; i < frm.pro.length; i++)
    {

        if (frm.pro[i].checked)
        {

                values = frm.pro[i].value + ",";

        }
    }
    alert(values);   << it is empty
    ....
    //pass values to the back-end
Run Code Online (Sandbox Code Playgroud)

javascript jquery struts2

2
推荐指数
1
解决办法
1万
查看次数

Org.hibernate.HibernateException:没有活动事务,createQuery无效

在这个问题之后,我试图将Hibernate 4.3.8.Final添加到Spring 4.1.5.RELEASE; 但是 - 代码抛出一个异常,因为跟随并且有时抛出 - 它无法找到hibernate的实体类(com.myproject.model.MyTable),尽管该类存在且位于com.myproject.model包中.

堆栈跟踪

org.hibernate.HibernateException: createQuery is not valid without active transaction
    at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:352)
    at com.sun.proxy.$Proxy40.createQuery(Unknown Source)
    at com.myproject.repository.TestRepImpl.get(TestRepImpl.java:21)
    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:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy33.get(Unknown Source)
    at com.myproject.service.TestServiceImpl.get(TestServiceImpl.java:17)
    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:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy35.get(Unknown Source) …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-mvc hibernate-4.x

2
推荐指数
1
解决办法
9395
查看次数

如何在Java中格式化非普通日期?

我有两个日期,需要格式化他们,但我收到以下异常.我的主要问题是th rd etc当天的部分.我找不到这个问题的答案.我检查了所有这些链接1,2,3,4,5,我想我应该用正则表达式,但不知道如何.

 10th Dec 2019 -> 2019-12-10 
 10th December 2019 -> 2019-12-10
Run Code Online (Sandbox Code Playgroud)

 String date1 = "10th Dec 2019";
 Date date = new SimpleDateFormat("dd MMMM YYYY").parse(date1);
 System.err.println(date);
 String date2 = new SimpleDateFormat("yyyy-mm-dd").format(date);
 System.err.println(date2);
Run Code Online (Sandbox Code Playgroud)

例外

 Exception in thread "main" java.text.ParseException: Unparseable date: "10th Dec 2019"
Run Code Online (Sandbox Code Playgroud)

java regex java-7

1
推荐指数
1
解决办法
486
查看次数

How to format a date to following format day.month.year?

I need to format a date to following format: 10.12.2014 and I am using the following code but it returns following error

   Messages:    
   Unparseable date: "2014-12-10"
Run Code Online (Sandbox Code Playgroud)

Code

   SimpleDateFormat formatter = new SimpleDateFormat("dd.mm.yyyy");
   Date date = formatter.parse(param.getFromDate());
   String formattedDate = formatter.format(date);
Run Code Online (Sandbox Code Playgroud)

java calendar simpledateformat

0
推荐指数
1
解决办法
7226
查看次数

为什么<a>标签用%2520替换空格?如何解决这个问题?

在这种情况下,我想解释问题,因为场景将是解释它的最佳方式.

我在页面中有一个搜索框,A.html传递给此页面的参数应替换为其搜索框的值.问题是,当我传递参数时,空格会被替换,%2520因此错误的值将被添加到搜索框中.我需要解决它.

  1. <a href="www.example.com/a.html?value=Here and there">Link</a>

  2. 以下地址将被放入地址栏: www.example.com/a.html?value=Here%2520and%2520there

  3. 该值将替换为搜索框的值:Here%2520and%2520there.我需要"Here and There"在搜索框中输入此值.(没有%2520)

html javascript url

0
推荐指数
1
解决办法
1326
查看次数