我有一个应用程序,我有一个名为的类PlausibilityChecker.这个类只有静态方法,比如checkZipcodeFormat或checkMailFormat.我在GUI类中使用它们来检查输入,然后再将它发送到较低层.
这是好习惯吗?我以为我只使用静态方法,所以我不必关心将实例传递给GUI类或者在每个gui类中都有一个不引用gui对象的实例字段.
我注意到这个Files类Java NIO只有静态方法所以我认为这不是那么可怕的错误.
我可能错了,但根据我的理解,WildFly必须具备以下功能:
必须可以将我的JSF视图(即xhtml文件)链接到WildFly服务器上已有的资源(pdf,图像,其他xhtml文件).
我可以在php和apache服务器上做同样的事情.
我需要在哪里放置这些资源,如何从我的视图中访问它们?E. g.将视图中的链接放到pdf文件中,该文件在新选项卡中打开pdf文件.
非常感谢您的提示和提示!!
编辑
standalone.xml
<server name="default-server">
<http-listener name="default" socket-binding="http" max-post-size="974247881"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<location name="/content" handler="ContentDir"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
<file name="ContentDir" path="${jboss.home.dir}/standalone/data/unzipped" directory-listing="true"/>
</handlers>
Run Code Online (Sandbox Code Playgroud)
链接在JSF视图中
<h:outputLink value="http://localhost:8181/content">KLICK</h:outputLink>
Run Code Online (Sandbox Code Playgroud)
当我点击这个时,我得到目录列表,如你所说.
但是我怎样才能使它显示index.xhtml在content指向的目录中?这就是我想要的.
content指向${jboss.home.dir}/standalone/data/unzipped和解压缩有一个index.xhtml以及另一个包含更多.xhtml文件的文件夹.
在文件夹中的文件index.xhtml有相对链接.xhmtl:
<ul>
<li><a href="t/rt.html">hg</a></li>
<li><a href="t/tert.html">jghj</a></li>
<li><a href="t/gf.html">jghj</a></li>
<li><a href="t/hg.html">jghj</a></li>
<li><a href="t/hgfh.html">jghj</a></li>
<li><a href="t/hfgh.html">jhgj</a></li>
<li><a href="t/hfgh.html">jhgj</a></li> …Run Code Online (Sandbox Code Playgroud) 如果存在注册表值,我需要检查.我怎样才能做到这一点?
我的第一个方法:
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:"
${IF} $0 == ""
MESSAGEBOX MB_OK "NUL exists"
${ELSE}
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:" ""
${ENDIF}
Run Code Online (Sandbox Code Playgroud)
但是当价值不存在时,这也有效.我猜,因为"不存在",空字符串的处理方式相同.
使用Registry.nsh我这样做:
${registry::Read} "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:" $var1 $var2
${IF} $var2 == "REG_SZ"
Run Code Online (Sandbox Code Playgroud)
但是我收到错误,因为registry.nsh中的Pop $ {_ STRING}不起作用.
欢迎提出帮助和建议!
我和这个家伙有类似的问题:
但我不需要编号,我只是想了解它的工作方式:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a>blah</a>
<a>blah</a>
<a>blah</a>
<a>blah</a>
</test>
Run Code Online (Sandbox Code Playgroud)
对于此输入,以下样式表:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="select">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a">
<xsl:value-of select="position()"/><br/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
输出:
<html><body>
2<br>blah
4<br>blah
6<br>blah
8<br>blah
</body></html>
Run Code Online (Sandbox Code Playgroud)
为什么跳过不均匀的数字?
我想用xslt 2.0检查文件是否存在.但是,它不起作用.我试过这个:
<xsl:choose>
<xsl:when test="doc(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))">
Run Code Online (Sandbox Code Playgroud)
(路径正确)
但是,当文件不存在时,这会导致错误.
还有这个:
<xsl:choose>
<xsl:when test="doc-available(iri-to-uri(concat($currFolder, '/', $currSubFolder, '/', @href)))">
Run Code Online (Sandbox Code Playgroud)
它不起作用,它告诉我文件在那里显然不存在.
这是正确的方法吗?如果存在xml文件,则检查的可靠方法.
我有一个REST资源,它被RestTemplateBuilder注入以构建一个RestTemplate:
public MyClass(final RestTemplateBuilder restTemplateBuilder) {
this.restTemplate = restTemplateBuilder.build();
}
Run Code Online (Sandbox Code Playgroud)
我想测试那个课程.我需要模拟RestTemplate对其他服务的调用:
request = restTemplate.getForEntity(uri, String.class);
Run Code Online (Sandbox Code Playgroud)
我在我的IT中试过这个:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class MyIT {
@Autowired
private TestRestTemplate testRestTemplate;
@MockBean
private RestTemplateBuilder restTemplateBuilder;
@Mock
private RestTemplate restTemplate;
@Test
public void shouldntFail() throws IOException {
ResponseEntity<String> responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND);
when(restTemplateBuilder.build()).thenReturn(restTemplate);
when(restTemplate.getForEntity(any(URI.class), any(Class.class))).thenReturn(responseEntity);
...
ResponseEntity<String> response = testRestTemplate.postForEntity("/endpoint", request, String.class);
...
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我得到以下异常:
java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean …Run Code Online (Sandbox Code Playgroud) 我有一个问题GridSearchCV:
通过使用这个:
gs_clf = GridSearchCV(pipeline, parameters, n_jobs=-1, cv=6, scoring="f1")
Run Code Online (Sandbox Code Playgroud)
我指定 k 折交叉验证应该与 6 折一起使用,对吗?
所以这意味着我的语料被分成了 6 次训练集和 tet 集。
这是否意味着GridSearchCV我需要使用我的整个语料库,如下所示:
gs_clf = gs_clf.fit(corpus.data, corpus.target)
Run Code Online (Sandbox Code Playgroud)
如果是这样,我将如何从那里获得用于预测方法的训练集?
predictions = gs_clf.predict(??)
Run Code Online (Sandbox Code Playgroud)
我所看到的代码,其中的语料分成测试组,并使用训练集train_test_split,然后X_train并Y_train传递给gs_clf.fit。
但这对我来说没有意义:如果我事先将其拆分为语料库,为什么要在GridSearchCV.
感谢您的一些澄清!!
This is my current routing table (I rearranged it and grouped it by interface):
Destination Network mask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.178.1 192.168.178.28 50
192.168.178.0 255.255.255.0 On-link 192.168.178.28 306
192.168.178.28 255.255.255.255 On-link 192.168.178.28 306
192.168.178.255 255.255.255.255 On-link 192.168.178.28 306
224.0.0.0 240.0.0.0 On-link 192.168.178.28 306
255.255.255.255 255.255.255.255 On-link 192.168.178.28 306
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
192.168.56.0 255.255.255.0 On-link 192.168.56.1 281 …Run Code Online (Sandbox Code Playgroud) 两者之间有什么区别?什么时候可以使用另一个?
在Spring Security文档中,它说WebMvcConfigurer具有以下功能:
要求对应用程序中的每个URL进行身份验证
该WebSecurityConfigurerAdapter所示例子HttpSecurity说:
确保对我们应用程序的任何请求都需要对用户进行身份验证。
是不是一样?
编辑
这两种类型的配置似乎有不同的用途,我只是不太了解何时使用哪种配置:每种配置类型的两种不同情况是什么?
在HttpSecuriy部分的简介中,它说
Spring Security如何知道我们要要求所有用户进行身份验证?Spring Security如何知道我们要支持基于表单的身份验证?
所以现在我在想:第一个提示对用户进行身份验证时会发生什么,第二个提示在什么情况下需要对用户进行身份验证。那是对的吗?
例如,第一个配置“为您生成一个登录表单”,第二个配置确定何时应显示该登录表单?
我想使用Google的JIMFS创建用于测试目的的虚拟文件系统.不过,我很难入门.
我查看了这个教程:http://www.hascode.com/2015/03/creating-in-memory-file-systems-with-googles-jimfs/
但是,当我创建文件系统时,它实际上是在现有文件系统中创建的,即我不能这样做:
Files.createDirectory("/ virtualfolder");`因为我被拒绝访问.
我错过了什么吗?
目前,我的代码看起来像这样:
测试类:
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path vTargetFolder = fs.getPath("/Store/homes/linux/abc/virtual");
TestedClass test = new TestedClass(vTargetFolder.toAbsolutePath().toString());
Run Code Online (Sandbox Code Playgroud)
Java类在某处:
targetPath = Paths.get(targetName);
Files.createDirectory(targetPath);
// etc., creating files and writing them to the target directory
Run Code Online (Sandbox Code Playgroud)
但是,我创建了一个单独的类来测试JIMFS,这里目录的创建并没有失败,但是我不能像这样创建一个新文件:
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path data = fs.getPath("/virtual");
Path dir = Files.createDirectory(data);
Path file = Files.createFile(Paths.get(dir + "/abc.txt")); // throws NoSuchFileException
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?