我只是想知道如何将jqGrid列宽设置为auto?
...
colModel: [
{ name: 'MyDescription', index: 'description', align: 'left', width: 150, sortable: false },
...
Run Code Online (Sandbox Code Playgroud)
对于上述语句,如何为列指定自动宽度,使其适合其中最大内容的大小.
我有一个这样的模型:
private String message;
private Integer errorCode;
private String data;
Run Code Online (Sandbox Code Playgroud)
我从远程和消息中获取JSON字符串,errorCode变量获取正确的值.但是我不想反序列化到我的数据变量.我希望它是一个json字符串,如:
{"data": {"cat": "1.2.3.4", "ner": "80", "name": "pinta" }, "message" : "m", "errorCode" : 12}
Run Code Online (Sandbox Code Playgroud)
之后,我将反序列化它以反对自己.我怎样才能做到这一点?
PS:澄清问题:
我得到一个类似的Json字符串:
{"data":{"cat":"1.2.3.4","ner":"80","name":"pinta"},"message":"m","errorCode":12}
反序列化后,我的变量应具有以下值:
{"cat": "1.2.3.4", "ner": "80", "name": "pinta" }
Run Code Online (Sandbox Code Playgroud) <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我在项目的pom.xml中使用了依赖项导入.我的问题是我宣布2.5为版本.但是,编写较低版本是否重要?例如,我的意思是,如果我的项目使用3.0版本,我写的将提供2.5?(我的意思是让我们接受2.5很好,我的项目运作良好,如果我不改变其他任何东西,只需将2.5更改为2.0会导致错误吗?)
Spring Security参考说明:
您可以使用多个元素为不同的URL集定义不同的访问要求,但它们将按列出的顺序进行评估,并将使用第一个匹配项.所以你必须把最具体的比赛放在最上面.您还可以添加方法属性以限制与特定HTTP方法(GET,POST,PUT等)的匹配.如果请求与多个模式匹配,则无论排序如何,特定于方法的匹配都将优先.
如何配置Spring Security,以便根据用于访问URL模式的HTTP方法,以不同方式保护对特定URL模式的访问?
如何使用Spring Security 3散列密码并加密它们?
我正在检查Bram Jetten的js文件:
Notification.fn = Notification.prototype;
function Notification(value, type, tag) {
this.log(value, type);
this.element = $('<li><span class="image '+ type +'"></span>' + value + '</li>');
if(typeof tag !== "undefined") {
$(this.element).append('<span class="tag">' + tag + '</span>');
}
$("#notifications").append(this.element);
this.show();
}
/**
* Show notification
*/
Notification.fn.show = function() {
$(this.element).slideDown(200);
$(this.element).click(this.hide);
}
/**
* Hide notification
*/
Notification.fn.hide = function() {
$(this).animate({opacity: .01}, 200, function() {
$(this).slideUp(200, function() {
$(this).remove();
});
});
}
...
Run Code Online (Sandbox Code Playgroud)
我为我的按钮分配了一个点击事件,当我点击该按钮时,它会调用一个新的通知:
new Notification('Hi', 'success');
Run Code Online (Sandbox Code Playgroud)
当我点击该通知时它也会关闭.但是,如果我在一段时间后没有点击它,我希望它自己关闭.我怎样才能调用隐藏功能,或者在它出现一段时间后将其关闭?
我能够使用RestTemplate并自动装配它.但是,我想将我的其余模板相关的代码部分移动到另一个类中,如下所示:
public class Bridge {
private final String BASE_URL = "http://localhost:8080/u";
@Autowired
RestTemplate restTemplate;
public void addW() {
Map<String, String> x = new HashMap<String, String>();
W c = restTemplate.getForObject(BASE_URL + "/device/yeni", W.class, x);
System.out.println("Here!");
}
}
Run Code Online (Sandbox Code Playgroud)
在另一个班级我称之为:
...
Bridge wb = new Bridge();
wb.addW();
...
Run Code Online (Sandbox Code Playgroud)
我是Spring和依赖注入术语的新手.我的restTemplate 变量为null并抛出异常.我该怎么做才能解决它(我不知道它与我使用 new关键字有关)?
我写了这段代码:
public static void main(String args[]) throws Exception {
String template = "The user has spent amount in a day";
String pattern = "amount";
String output = template.replaceAll(pattern, "$ 100");
System.out.println(output);
}
Run Code Online (Sandbox Code Playgroud)
这是我运行时发生的事情:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
at java.util.regex.Matcher.appendReplacement(Matcher.java:713)
at java.util.regex.Matcher.replaceAll(Matcher.java:813)
at java.lang.String.replaceAll(String.java:2190)
at demo.BugDemo.main(BugDemo.java:16)
Java Result: 1
Run Code Online (Sandbox Code Playgroud)
我正在读取文件中的数据.我应该转义$文件数据中的所有符号,还是这是一个不必要的过程?还有其他类或库来处理这种情况吗?
在替换文本中使用特殊符号(而不是在正则表达式中)有什么问题?
笔记:
我不想检查每个角色逃脱.这就是我问这个问题的原因.
我正在使用Java 6.
当我尝试从服务器下载260MB的大文件时,我收到此错误:java.lang.OutOfMemoryError: Java heap space.我确定我的堆大小小于252MB.有没有办法在不增加堆大小的情况下下载大文件?
如何在不解决此问题的情况下下载大文件?我的代码如下:
String path= "C:/temp.zip";
response.addHeader("Content-Disposition", "attachment; filename=\"test.zip\"");
byte[] buf = new byte[1024];
try {
File file = new File(path);
long length = file.length();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
ServletOutputStream out = response.getOutputStream();
while ((in != null) && ((length = in.read(buf)) != -1)) {
out.write(buf, 0, (int) length);
}
in.close();
out.close();
Run Code Online (Sandbox Code Playgroud) 我指示我的URL发送类似的Ajax请求:
url += '/' + something + '/' + id;
var response;
$.ajax({
async : false,
type: 'DELETE',
url: url,
...
Run Code Online (Sandbox Code Playgroud)
我removeId是一个包含UTF-8字符的变量.我将在Java端处理该变量:
@RequestMapping(value = "/something/{id}", method = RequestMethod.DELETE)
public void myMethod(HttpServletResponse response, @PathVariable String id) {
...
Run Code Online (Sandbox Code Playgroud)
然而id,Java端的变量与原始变量不同,因为UTF-8字符变为奇怪的东西.
如何从JavaScript端发送UTF-8字符并在我的Java端再次转换它(Spring 3 with REST,我的Web服务器是Tomcat 7)?
PS 1:即使我不使用encodeUriComponent它似乎我的URL本身编码?
PS 2:提出更清楚的问题:
i.e. my id variable is araç and sent URL is: localhost:8080/sdfasf/ara%C3%A7
Run Code Online (Sandbox Code Playgroud)
当我看到id变量具有该值时:
araç
Run Code Online (Sandbox Code Playgroud)
代替:
ara%C3%A7
Run Code Online (Sandbox Code Playgroud)
Spring(或Tomcat)会自动执行此操作吗?当控制器作为路径变量时,有没有办法自动解码它(我的意思是没有写任何东西:
URLDecoder.decode(id,"UTF-8");
Run Code Online (Sandbox Code Playgroud)
它会自动转换)