我有一个问题是将h:selectBooleanCheckbox的列表绑定到我的bean.有人帮忙吗?
这不起作用:
<ui:repeat value="#{cartBean.productsList}" var="cartProduct" varStatus="i">
<h:selectBooleanCheckbox binding="#{cartBean.checkboxes[i.index]}" />
</ui:repeat>
public class CartBean extends BaseBean {
public List<Product> getProductsList() {...}
private HtmlSelectBooleanCheckbox[] checkboxes;
public HtmlSelectBooleanCheckbox[] getCheckboxes() {
return checkboxes;
}
public void setCheckboxes(HtmlSelectBooleanCheckbox[] checkboxes) {
this.checkboxes = checkboxes;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
javax.faces.FacesException: javax.el.PropertyNotFoundException: /WEB-INF/flows/main/cart.xhtml @26,97 binding="#{cartBean.checkboxes[i.index]}": Target Unreachable, 'checkboxes' returned null
Run Code Online (Sandbox Code Playgroud)
我解决了我的问题.我使用下面的代码得到我想要的东西(感谢BalusC博客 - http://balusc.blogspot.com/2006/06/using-datatables.html#SelectMultipleRows):
<ui:repeat value="#{cartBean.productsList}" var="cartProduct" varStatus="i">
<h:selectBooleanCheckbox value="#{cartBean.selectedIds[cartProduct.id]}" />
</ui:repeat>
public class CartBean extends BaseBean {
private Map<Integer, Boolean> selectedIds = new HashMap<Integer, Boolean>();
public Map<Integer, Boolean> …Run Code Online (Sandbox Code Playgroud) 我在下面的web-app中使用logout方法,但是如果我检查remember me注销不起作用,因为cookie没有被清除.如何在我的方法中以编程方式清除此cookie(或如何更好地注销方法)?
public void logout() {
AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("anonymous", "anonymous", new ArrayList(Arrays.asList(new GrantedAuthorityImpl("ROLE_ANONYMOUS"))));
SecurityContextHolder.getContext().setAuthentication(anonymous);
}
Run Code Online (Sandbox Code Playgroud) 将一些文件资源注入Spring bean的好方法是什么?现在我自动装配ServletContext并使用如下所示.在Spring MVC中更优雅的方式吗?
@Controller
public class SomeController {
@Autowired
private ServletContext servletContext;
@RequestMapping("/texts")
public ModelAndView texts() {
InputStream in = servletContext.getResourceAsStream("/WEB-INF/file.txt");
// ...
}
}
Run Code Online (Sandbox Code Playgroud) 在同一个表中复制记录的最佳方法是什么?
像这样的东西:
Address address = AddressDAO.get(id);
address.setId(null);
AddressDAO.add(address);
Run Code Online (Sandbox Code Playgroud) 什么是创建一个包含HTML(使用正确的编码),一个String对象(我想),我可以在返回列举了最简单,最快捷的方式@ResponseBody(Spring MVC的)?
如何简单@RequestParam或@PathVariable访问Spring MVC Controller中的"请求有效负载"?

我有工作的servlet需要转换为Spring MVC控制器才能访问spring bean等.为什么在普通的servlet中request.getPathInfo()没有返回null,但在Spring Controller中我得到null值?我知道我可以使用@PathVariable,但想知道为什么这种方法的结果有区别?
@RequestMapping(value = {"/test", "/test/*"})
public void test(HttpServletRequest req, HttpServletResponse res) {
log.info(req.getPathInfo() == null); // true!
if (req.getMethod().equalsIgnoreCase("get")) {
// analogue to doGet...
} else {
// analogue to doPost...
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用GWT(2.4)和Spring集成,如本文所述.从数据库(Hibernate)获取User列表并使用它填充DataGrid时遇到问题.当我调用greetingService.allUsers()方法时,我收到错误(onFailure()):
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException:无法反序列化响应
有人帮忙吗?下面是一些代码.完整的工作项目在这里.
public void onModuleLoad() {
// ...
greetingService.allUsers(
new AsyncCallback<List<User>>(){
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
@Override
public void onSuccess(List<User> result) {
GWT.log("SIZE: "+result.size());
dataGrid.setRowData(result);
}
}
);
// ...
}
Run Code Online (Sandbox Code Playgroud)
GreetingServiceImpl
@Override
public List<User> allUsers() {
return userDAO.findAll();
}
Run Code Online (Sandbox Code Playgroud)
用户
@Entity
@Table(name = "users")
public class User implements Serializable, IsSerializable {
@Id
private Long id;
// only Strings and one Date
private String login;
private String password; …Run Code Online (Sandbox Code Playgroud) 我有例如.pdf文件(该文件的路径).如何在SWT应用程序的默认应用程序(可能是Acrobat Reader)中打开此文件(例如,单击按钮)?