Skip to content

Instantly share code, notes, and snippets.

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
Include file (Java)
<%@ include file="/WEB-INF/jsp/common/date.jsp" %>
Include file (JSP)
<jsp:include page="/WEB-INF/jsp/common/date.jsp">
package com.concretepage.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import com.concretepage.bean.UserInfo;
@Repository
public class Messages {
// property file is: package/name/messages.properties
private static final String BUNDLE_NAME = "package.name.messages";
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
package com.howtodoinjava.demo.validator;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import com.howtodoinjava.demo.model.EmployeeVO;
@Component
package com.howtodoinjava.demo.model;
import java.io.Serializable;
public class EmployeeVO implements Serializable
{
private static final long serialVersionUID = 1L;
private Integer id;
private String firstName;
// list page
@RequestMapping(value = "/users", method = RequestMethod.GET)
public String showAllUsers(Model model) {
logger.debug("showAllUsers()");
model.addAttribute("users", userService.findAll());
return "users/list";
}
/**
* Form post handler
*/
@RequestMapping(value = "/", method = RequestMethod.POST)
public String send(
@Valid @ModelAttribute("messageForm") MessageForm messageForm,
BindingResult binding,
RedirectAttributes redirectAttributes) {
// Redirect back into form page if errors detected