我有资源包作为Java类从数据库中读取值.当我更新数据库我需要重新加载包,但我不知道如何.有人帮忙吗?
package model.helpers;
public class Messages_en extends ListResourceBundle {
protected Object[][] getContents() {
// from DB
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
在视图中我使用bundle如下:
<f:loadBundle basename="model.helpers.Messages" var="m" />
Run Code Online (Sandbox Code Playgroud) 是一种在JSP中访问视图名称的方法(profile在下面的示例中),或者我需要将此名称添加到模型中?
@RequestMapping(value="/user/account", method=RequestMethod.GET)
return "profile";
}
Run Code Online (Sandbox Code Playgroud) 是否可以在Eclipse中访问Maven(嵌入式)控制台,如在shell(linux shell,windows cmd.exe)中运行自定义maven命令(mvn archetype:create .... etc)?我正在使用m2e,但只能通过GUI运行Maven命令.
每次我在java.util.List上使用.remove()方法我得到错误UnsupportedOperationException.这让我很疯狂.转换为ArrayList没有帮助.怎么做 ?
@Entity
@Table(name = "products")
public class Product extends AbstractEntity {
private List<Image> images;
public void removeImage(int index) {
if(images != null) {
images.remove(index);
}
}
}
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
java.lang.UnsupportedOperationException
java.util.AbstractList.remove(AbstractList.java:144)
model.entities.Product.removeImage(Product.java:218)
...
Run Code Online (Sandbox Code Playgroud)
我看到我需要使用比List接口更精确的类,但是在ORM示例列表中的每一个都使用...
为什么单击trigger1并且trigger2不点击open?
<a id="trigger1" href="#" onclick="jQuery('#open').trigger('click');">trigger1</a>
<a id="trigger2" href="#" onclick="jQuery('#open').click();">trigger2</a>
<a id="open" href="http://google.com">open</a>
Run Code Online (Sandbox Code Playgroud)
使用ready(trigger3)也不起作用:
<a id="trigger3" href="#">trigger3</a>
Run Code Online (Sandbox Code Playgroud)
...
jQuery(document).ready(function(){
jQuery('#trigger3').bind('click', function(){
jQuery('#open').html('to be fired'); /* works */
jQuery('#open').click();
});
jQuery('#trigger3').click(function(){
jQuery('#open').html('to be fired'); /* works */
jQuery('#open').click();
});
});
Run Code Online (Sandbox Code Playgroud) 我有两个很长但已排序的文件.如何获取不在第二个文件中的第一个文件的所有行?
文件1
0000_aaa_b
0001_bccc_b
0002_bcc <------ file2 have not that line
0003_aaa_d
0006_xxx
...
Run Code Online (Sandbox Code Playgroud)
文件2
0000_aaa_b
0001_bccc_b
0003_aaa_d
0006_xxx
...
Run Code Online (Sandbox Code Playgroud) 我在WEB-INF/config/applicationContext.xml中使用applicationContext.xml工作web应用程序.现在我需要将一些测试工具实现为独立应用程序,它可以使用相同的applicationContext.xml,但是对于ClassPathXmlApplicationContext类的配置路径有问题.
我知道当我将applicationContext.xml复制到默认包(其中.java所在的位置)时,我可以使用ClassPathXmlApplicationContext("applicationContext.xml"),但这是必要的吗?
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class AdminTool {
private Logger log = Logger.getLogger(getClass());
/** all below doesn't work - FileNotFoundException) **/
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("/WEB-INF/config/applicationContext.xml");
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("config/applicationContext.xml");
private static final ApplicationContext ac = new ClassPathXmlApplicationContext("../config/applicationContext.xml");
public static void main(String[] args) {
new AdminTool();
}
public AdminTool() {
log.debug(ac);
}
}
Run Code Online (Sandbox Code Playgroud) 我得到ajax响应为JSON,需要用它填充表单.如何在jQuery或其他东西中做到这一点?有什么比使用更好的东西$(json).each()?
JSON:
{
"id" : 12,
"name": "Jack",
"description": "Description"
}
Run Code Online (Sandbox Code Playgroud)
填写表格
<form>
<input type="text" name="id"/>
<input type="text" name="name"/>
<input type="text" name="description"/>
</form>
Run Code Online (Sandbox Code Playgroud) 我喜欢SimpleMappingExceptionResolver,因为在一个地方我有web-app中所有控制器的所有异常 - >视图映射(我想).要在我希望使用的特定控制器中自定义一些异常@ExceptionHandler,但它不能一起工作 - 所有异常都由处理SimpleMappingExceptionResolver.如何使这项工作在一起?
@Controller
public class SomeController {
...
@ExceptionHandler(SomeException.class)
public ModelAndView handleException(Exception ex) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
的SimpleMappingExceptionResolver:
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView" value="error"/>
<property name="exceptionMappings">
...
</property>
</bean>
Run Code Online (Sandbox Code Playgroud) java ×4
jquery ×2
spring ×2
spring-mvc ×2
collections ×1
eclipse ×1
javascript ×1
jsf ×1
jsf-2 ×1
json ×1
layout ×1
linux ×1
maven ×1
swt ×1
toolbar ×1