我有一个受密码保护的私钥,可以通过SSH访问服务器.
我有2台linux(ubuntu 10.04)机器,ssh-add命令的行为在两者中都不同.
在一台机器上,一旦我使用"ssh-add .ssh/identity"并输入我的密码,密钥就会被永久添加,即每次关闭计算机并再次登录时,密钥都已添加.
在另一个中,我必须在每次登录时添加密钥.
据我记忆,我对两者做了同样的事情.唯一的区别是密钥是在永久添加的密钥上创建的.
有谁知道如何永久地将它添加到其他机器?
我需要在div的右上角显示一个图像(图像是一个"对角线"功能区),但保持当前文本包含在内部div中,就像现在一样粘在它的顶部.
我尝试了不同的东西,包括在另一个div中的图像或定义它的类,如:
.ribbon {
position: relative;
top: -16px;
right: -706px;
}
<div id="content">
<img src="images/ribbon.png" class="ribbon"/>
<div>some text...</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但没有任何运气.我得到的最好结果是所有文本都向下滚动了相同的图像高度.
任何的想法?
是否可以通过内联CSS加载外部字体?
注意:我不是在谈论使用带有@font-face定义的外部CSS文件,而是如下所示:
<h1 style="font-family:myfont;
src:('http://example.com/font/myfont.tff')">test</h1>
Run Code Online (Sandbox Code Playgroud) 在我的Spring 3.0应用程序中,我有一些资源/WEB-INF/dir.在运行时,我需要它们中的InputStream一些(或其他类型).我怎样才能找回它们?是否可以将它们作为正常注射Resource?
在我的代码中,我有这样的事情:
private void doSomething() {
Calendar today = Calendar.getInstance();
....
}
Run Code Online (Sandbox Code Playgroud)
如何在我的junit测试中"模拟"它以返回特定的日期?
当我用maven创建war包时,目录"src/main/resources"下的文件和目录被复制到/ WEB-INF/classes而不是/ WEB-INF中.如何将它们复制到/ WEB-INF中?
谢谢,兰德
更新:在我的pom中我现在使用这个:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>war</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>myapp/target/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我用以下命令启动mvn:
mvn -Dmaven.test.skip =真正的干净包资源:copy-resources
但我得到了:
[INFO] One or more required plugin parameters are invalid/missing for 'resources:copy-resources'
[0] Inside the definition for plugin 'maven-resources-plugin' specify the following:
<configuration>
...
<outputDirectory>VALUE</outputDirectory>
</configuration>.
[1] Inside the definition for plugin 'maven-resources-plugin' specify the following:
<configuration>
...
<resources>VALUE</resources>
</configuration>.
Run Code Online (Sandbox Code Playgroud)
我正在使用maven …
Spring MVC(3.0)将带有和不带尾部斜杠的URL视为相同的URL.
例如:
http://www.example.org/data/something = http://www.example.org/data/something/
我需要使用尾部斜杠重定向URL
到没有它的URL:
我需要在应用程序内部执行此操作(因此不要通过Apache重写规则等).
一种方法是:
@ResponseStatus(value=HttpStatus.MOVED_PERMANENTLY)
@RequestMapping(value = "/data/something/")
public String dataSomethingRedirect(...) {
return "redirect:/data/something";
}
Run Code Online (Sandbox Code Playgroud)
但这通常有两个问题:
有没有办法拦截所有的URL,如果它们有一个尾部斜杠,将它们重定向到没有斜杠的相对URL?
我想在表中添加一些列(Swing JTable).其中一些将具有默认大小(例如250),其他将被隐藏(因此它们的大小将为0).我用这个代码:
model = new DefaultTableModel();
table = new JTable(model);
setAutoResizeMode(AUTO_RESIZE_OFF);
for (int i = 1; i < COLUMN_NAMES.length; i++) {
model.addColumn(COLUMN_NAMES[i]);
if (show[i]) show(index);
else hide(index);
}
........
private void hide(int index) {
TableColumn column = getColumnModel().getColumn(index);
column.setMinWidth(0);
column.setMaxWidth(0);
column.setWidth(0);
column.setPreferredWidth(0);
doLayout();
}
private void show(int index) {
final int width = 250;
column.setMinWidth(15);
column.setMaxWidth(width);
column.setWidth(width);
column.setPreferredWidth(width);
doLayout();
}
Run Code Online (Sandbox Code Playgroud)
问题是当显示表格时,显示所有列(没有隐藏),它们的大小不是250,但它们具有相同的大小.
我怎样才能得到想要的效果?
我需要使用Java Swing创建一个可点击的标签,并且能够打开桌面上的默认浏览器并将其重定向到特定的URL.我的代码能够打开浏览器,但不能将其重定向到正确的URL(加载默认主页).我的测试代码:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.*;
public class LinkTest extends JFrame {
public LinkTest() {
JPanel p = new JPanel();
JLabel link = new JLabel("Click here");
link.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
link.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 0) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
URI uri = new URI("http://www.bbc.co.uk");
desktop.browse(uri);
} catch (IOException ex) {
ex.printStackTrace();
} catch (URISyntaxException ex) {
ex.printStackTrace();
}
}
}
}
});
p.add(link);
getContentPane().add(BorderLayout.NORTH, …Run Code Online (Sandbox Code Playgroud) 在这样的测试中:
@Test
public void test() {
List<String[]> l = new LinkedList<String[]>();
l.add(new String [] {"test", "123"});
l.add(new String [] {"test", "456"});
l.add(new String [] {"test", "789"});
assertEquals(3, l.size());
l.remove(new String [] {"test", "456"});
assertEquals(2, l.size());
}
Run Code Online (Sandbox Code Playgroud)
作为第二断言(= 2)不equals/hashcode使用在list.remove是default为对象.有没有办法让列表能够Arrays.equals/Arrays.hashcode用于比较数组?或者唯一的解决方案是将String数组包装在一个对象中并覆盖equals/hashcode?