Diskuze: JSP a procedura
V předchozím kvízu, Online test znalostí Java, jsme si ověřili nabyté zkušenosti z kurzu.
Zobrazeno 4 zpráv z 4.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
V předchozím kvízu, Online test znalostí Java, jsme si ověřili nabyté zkušenosti z kurzu.
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CLeaner</title>
</head>
<body>
<h1>Clean data</h1>
<form action = "Clean" method="POST">
Date for clean: <input type = "date" name = "date">
<input type = "submit" value = "Submit" />
</body>
</html>
package com.cgi.prepare;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CallClean {
@Autowired
private DataSource dataSource;
private Date date;
public void setDate(Date date) {
this.date = date;
}
public Date getDate() {
return date;
}
public void clean() {
try (Connection connection = dataSource.getConnection()) {
CallableStatement preparedCall = connection.prepareCall("call
Cleaner('"+date+"')");
preparedCall.executeQuery();
preparedCall.close();
connection.close();
} catch (Exception e) {
// TODO: handle exception
}
}
}
@Controller
public class CleanController {
@RequestMapping(value = "/clean", method = RequestMethod.GET)
public ModelAndView clean() {
return new ModelAndView("clean","command",new CallClean());
}
@RequestMapping(value = "/afterClean", method = RequestMethod.POST)
public String aftercleans(@ModelAttribute("SpringWeb")CallClean call,
ModelMap model) {
model.addAttribute("afterClean", call.getDate());
return "result";
}
}
}
Zobrazeno 4 zpráv z 4.