小编Lit*_*ird的帖子

UrlValidator不适用于localhost

我正面临一个问题,我在我的代码中使用了UrlValidator.

UrlValidator urlValidator = UrlValidator.getInstance();
    if(urlValidator.isValid(url)) {
        throw new IllegalArgumentException( url + "not valid");
    }
 where url i'm passing is 

 [1]: http://localhost:8080/myapp/Education.html
Run Code Online (Sandbox Code Playgroud)

如果我正在传递url,我将收到IllegalArgumentException

 [2]: https://www.google.co.in/
Run Code Online (Sandbox Code Playgroud)

它的工作正常.如何使此代码适用于localhost:8080

java url-validation

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

将文件的路径位置更改为所需的路径

我想将定义到文件中的内容路径(即logging.properties)替换为jboss7位置的所需位置路径.

基本上我使用安装程序,我必须浏览我的jboss7文件夹,并将其定位到用户的任何所需位置.但是在jboss7的少数文件中,有一些硬编码路径被定义为在给定的logging.properties文件中.

我需要将该硬编码路径更改为所需的位置路径.

截至目前,我在同一个文件夹中有repl.bat和文件test.bat文件.

repl.bat帮助文件可以在以下链接中找到: -

http://www.dostips.com/forum/viewtopic.php?f=3&t=3855

我刚刚复制了代码并创建了repl.bat文件.

test.bat文件: -

 @ECHO OFF
 SETLOCAL
 SET "folder="
 FOR /r "C:\" %%a IN (tintin.txt) do IF EXIST "%%a" SET "folder=%%~dpa"&GOTO got1
 FOR /r "D:\" %%a IN (tintin.txt) do IF EXIST "%%a" SET "folder=%%~dpa"&GOTO got1
 :got1
 echo "%folder%"
 PAUSE

 set "newpath=%folder%"
 set "newpath=%newpath:\=\\%"
 echo "%newpath%"
 PAUSE
 type "logging.properties" | repl "(Directory=).*(\\\\standalone\\\\)" "$1%newpath%$2">"logging.properties.tmp"
 PAUSE
 move "logging.properties.tmp" "logging.properties"
 PAUSE
 GOTO :EOF
 PAUSE
Run Code Online (Sandbox Code Playgroud)

在这个test.bat文件中,我正在搜索文件tintin.txt文件并将路径设置为变量名称为'folder'.tintin.txt文件就在jboss7的文件夹里面.这是因为有多个jboss7应用服务器文件夹进入系统的可能性.直到现在我有了路径即"C:\ Users\Anuj\Desktop\jboss7 \"并设置为变量'folder'.现在有一个名为logging.properties的文件到文件夹位置C:\ Users\Anuj\Desktop\jboss7\standalone\configuration

logging.properties: -

 com.latilla.import.uploadDirectory=C:\\progra~2\\Latilla\\C4i\\jboss7\\ standalone\\uploads
 com.latilla.import.maxFilesUploadNumber=10


com.latilla.export.templateFile=C:\\progra~2\\Latilla\\C4i\\jboss7\\standalone\\templates\\GDV_HDI_Format.xls
com.latilla.etl.pluginsRootDirectory=C:\\progra~2\\Latilla\\C4i\\jboss7\\standalone\\cloverETL\\plugins

 com.latilla.etl.templatesDirectory=C:\\progra~2\\Latilla\\C4i\\jboss7\\standalone\\etl

 com.latilla.db.user=postgres
 com.latilla.db.pass=password …
Run Code Online (Sandbox Code Playgroud)

batch-file

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

当网格中存在有限行时,滚动条不应显示

我的视图页面中有一个网格,我可以看到滚动条.当行数增加10时我需要的是滚动条应该是可见的,否则它应该是不可见的.kendoui有可能吗?

kendo-ui

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

如何替换json文件中的值

我有一个 JSON 文件,即test.json.

{
  "Added": {
    "type": "K",
    "newmem": {
      "IDNew": {
        "id": "777709",
        "type": "LOP"
      },
      "birthDate": "2000-12-09"
    },
    "code": "",
    "newest": {
      "curlNew": "",
      "addedForNew": ""
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我尝试了以下代码:

File file = new File("test.json");
JSONParser parser = new JSONParser();

JSONObject data =  (JSONObject) parser.parse(
   new FileReader(file.getAbsolutePath()
));//path to the JSON file.
System.out.println(data.toString());

JSONObject jObject  = new JSONObject();
jObject.put("id","12345678");
System.out.println(jObject);
Run Code Online (Sandbox Code Playgroud)

结果得到:-

{
  "Added": {
    "type": "K",
    "newmem": {
      "IDNew": {
        "id": "777709",
        "type": "LOP"
      },
      "birthDate": …
Run Code Online (Sandbox Code Playgroud)

java json

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

如何使用Grails 2.3.4连接postgres数据库

我是Grails的新手.我正在尝试使用grails 2.3.4连接postgresql 9.0数据库服务器.我已将postgresql-9.0-801.jdbc3.jar文件添加到grails应用程序的lib文件夹中.当我在Intellij编辑器上运行应用程序时,会出现以下错误.哪里我做错了?

|Running Grails application Error | 2013-12-08 18:44:55,837 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool. Message: Driver:org.postgresql.Driver@7c3b99 returned null for URL:jdbc:postgres://localhost/clientpro Line | Method ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run in java.util.concurrent.FutureTask | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 918 | run in '' ^ 662 | run . . in java.lang.Thread Error | 2013-12-08 18:44:55,877 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool. Message: Driver:org.postgresql.Driver@1ab5d6d returned …
Run Code Online (Sandbox Code Playgroud)

postgresql grails

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

如何在使用Selenium WebDriver触发的每个事件上自动测试Google Analytics

我正在使用Selenium WebDriver java绑定进行Google Analytics自动化测试.我们的网站在网站上的重要元素上设置了Google Analytics跟踪事件.我需要验证点击某个正在测试的元素时,Google Analytic事件实际上已被触发.

我在FireFox上测试它.当我点击F12时,我可以在控制台中看到Google Analytics会GET http://www.google-analytics.com/__utm.gif针对每个元素点击事件触发消息.

    SampleCode :-
      WebDriver wd = new FirefoxDriver();
      wd.get("http://www.dummyExample.com/");
      wd.findElement(By.linkText("Document Referece")).click();
      wd.findElement(By.id("Ex2vc2")).click();
Run Code Online (Sandbox Code Playgroud)

我怎样才能完成这项任务?我用谷歌搜索它但找不到好的答案.如果有人可以帮我提供一些参考或示例代码,我会非常感激.

javascript java selenium google-analytics selenium-webdriver

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

如何在视图页面上显示服务器端验证错误

因为我正在使用grails框架而不使用controller.My应用程序是"单页应用程序".我不想重新加载我的页面,所以我已经编写了服务,即使用Ajax调用的RegistrationService.所以我使用knockout进行数据绑定.使用的数据库是postgresql.我有一个视图页面,我有一个电子邮件字段.当我输入一个重复的电子邮件ID并单击保存按钮然后我可以看到验证错误,即"电子邮件已被采取"但即使我正在写一个唯一的ID,那么我也得到相同的验证错误.这是因为它在modalModal.js页面中出错了,所以我没有得到如何解决这个问题.我只想在输入唯一ID并单击"保存"按钮时,不应该给出验证错误.

_newCostingpage.gsp  (my view page)

    <div id="light" class="white_content" style="color: black;">
    <form action="#/cart" method="post">
    <input type="hidden" name="url" value="${grailsApplication.config.serverURL}"/>
    <p><label>first name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="firstName"
             class="formElement" data-bind='value: firstName'/></label></p>
    <p><label>last name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="lastName" 
              class="formElement" data-bind='value: lastName' /></label></p>
    <p><label>organisation: <input name="organisation" class="formElement" data-
              bind='value: organisation' /></label></p>
<p><label>email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="email" class="formElement" data-bind='value: email' /></label><label 
         id="errorDiv"></label></p>
<p><label>password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="password"
         class="formElement" data-bind='value: password' /></label></p>
 <p><label style="margin-left: -37px;">confirm password:</label> <input
        type="password" name="confirmPassword" class="formElement" data-bind='value:
        confirmPassword' /></p>
 <p><input type="submit" value="register"/></p>
</form>
 <a href="javascript:void(0)"onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none';clearBox();">Close</a>
        </div>
        <div id="fade" class="black_overlay"></div>
    </div>

Domain class …
Run Code Online (Sandbox Code Playgroud)

ajax grails sammy.js

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

在集成测试不起作用之前启动apache服务器

我有一个名为GroupWebApplication的Web应用程序.使用pom.xml文件我只是创建我的应用程序的战争并部署到tomcat服务器.这基本上是一个maven项目.我为tomcat7 apache服务器添加了插件.

现在我想要启动tomcat服务器,然后运行集成测试,在完成集成测试后,我想停止服务器.基本上我正在使用TestNg的testng.xml文件framework.testng.xml文件包含集成测试的所有类.手动它工作正常,即手动启动服务器并运行测试.

这是pom文件:

 <dependencies>

         <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.3.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>sGroupWebApplication Integration Test</finalName>
     <resources>
            <resource>
               <directory>src/main/resources</directory>
            </resource>
        </resources>
  <pluginManagement> 
    <plugins>
            <!-- Maven Tomcat Plugin -->
                        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>resource-dependencies</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>com.company.integration.test</includeGroupIds>
                            <includeArtifactIds>engine</includeArtifactIds>
                            <includes>**\/*.xpi,**\/*.exe,**\/*.so, **\/*.ftl,**\/*.css,**\/*.woff, **\/*.properties,**\/*.png,**\/chromedriver,**\/*.MF</includes>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <server>localhost</server>
      <path>/GroupWebApplication</path>
      <username>admin</username>
      <password>s3cret</password>
    </configuration>
    <executions>
          <execution>
            <id>tomcat7-run</id>
            <goals>
              <goal>run-war-only</goal>
            </goals>
            <phase>pre-integration-test</phase>
                <configuration>

                    <fork>true</fork> 
                </configuration>

           </execution>
           <execution>
            <id>tomcat7-shutdown</id>
            <goals>
              <goal>shutdown</goal>
            </goals>
            <phase>post-integration-test</phase>
          </execution>
        </executions> …
Run Code Online (Sandbox Code Playgroud)

java testng maven-2 maven-3 maven

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

集成测试前启动Apache tomcat服务器

过去 4 天我一直在寻找解决方案,并提出这个问题作为赏金,但仍然没有得到我的答案。

我在 pf pom.xml 文件的帮助下成功的地方:- a) 使用命令(即 mvn tomcat7:run)手动启动 tomcat 服务器。此命令还帮助我将 war 文件部署到 tomcat 服务器并启动服务器。b) 在 Eclipse 上使用 testng.xml 文件配置运行我的集成测试。

我在帮助 pf pom.xml 文件中失败的地方:-

a) 自动启动 tomcat 服务器。b) 运行所有集成测试。c) 停止 tomcat 服务器。

这个问题是我发布的,但找不到答案 在集成测试之前启动 apache 服务器不起作用

请帮助我错的地方。

testng maven-2 pom.xml maven

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

如何测试URL是否受SSL保护

我是IT行业的新手.测试场景就像我需要测试我的应用程序的登录页面是否受SSL保护?

通常,有时我们会访问某些网站,其中显示了SSL安全性的弹出窗口.所以我需要在我的应用程序中测试相同的场景.

我有一个小网页应用程序,我有login.html页面.基本上,我可以使用Maven启动我的Web应用程序,使用的服务器是Tomcat.我正在使用的命令是mvn tomcat7:run和URL一起使用http://localhost:8080/login.html.它完美地运作.

但我想我的网址,从改变httphttps,当我访问我的网址,即https://localhost:8080/login.html,那么它应该弹出与SSL安全警报,我应该接受它.

如果我的问题仍然不明确,请随时发表评论.

在网上搜索后,我做了一些解决方法,但它没有成功.我尝试过的:

我的HTML页面

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Login App</h1>
<div id="emptyDiv"></div>
<div id="description"></div>
<!--container start-->
<div id="container">
  <div id="container_body" style="background-color:#BBD700;float:center;">
  <!--Form  start-->
    <div id="form_name">
      <div class="firstnameorlastname">
<form >
     &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
       <div id="errorBox"></div>
         First Name :   <input  id="firstName" type="text" name="Name" value="" >
         &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
         Last name : <input  id="lastName" type="text" name="LastName" value="" >

      </div>
               &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
      <div id="email_form">
        Email Id: <input style="position:right" …
Run Code Online (Sandbox Code Playgroud)

java ssl tomcat web-applications maven

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