小编Ell*_*med的帖子

在数据库中保存MultipartFile/blob问题

嗨我想上传一个图像并将其存储在我使用spring mvc&hibernate的数据库中

这是模型

import java.sql.Blob;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;

@Entity
@Table(name = "article")
public class Article {

@Id
@GeneratedValue
@Column(name = "article_id")
private Long articleId;

@Column(name = "article_name", nullable = false, length=20)
private String articleName;

@Column(name = "article_desc", nullable = false)
private String articleDesc;

@Column(name = "date_added")
private Date addedDate;

 @Lob
    private Blob content;
public Article() {      
}

public Long getArticleId() {
    return articleId;
}

public void setArticleId(Long articleId) { …
Run Code Online (Sandbox Code Playgroud)

blob spring-mvc multipart

3
推荐指数
1
解决办法
9359
查看次数

知道纬度/经度/航向/速度的下一个位置

知道小数纬度,小数经度,速度(km/h),标题 如何在60秒后找到汽车的下一个位置?有什么算法可以做到吗?

c# algorithm gps

3
推荐指数
1
解决办法
3172
查看次数

Spring Mvc Controller - 删除问题

我在一个j2ee项目(pojo层,Dao层(hibernate),服务层(spring),View(spring mvc))工作我有一个文章表,每行后我想添加一个链接来删除它.

这是我的看法

<c:if test="${!empty articles}">
<table>
    <tr>
        <th>Article ID</th>
        <th>Article Name</th>
        <th>Article Desc</th>
        <th>Added Date</th>
        <th>operation</th>
    </tr>

    <c:forEach items="${articles}" var="article">
        <tr>
            <td><c:out value="${article.articleId}"/></td>
            <td><c:out value="${article.articleName}"/></td>
            <td><c:out value="${article.articleDesc}"/></td>
            <td><c:out value="${article.addedDate}"/></td>
            <td><a href="articles/${article.articleId}">delete</a></td>
        </tr>
    </c:forEach>
</table>
Run Code Online (Sandbox Code Playgroud)

这是要删除的控制器

@RequestMapping(value="/articles/{articleId}", method=RequestMethod.POST)
public String deleteContact(@PathVariable("articleId")
Integer articleId) {

    articleService.removeArticle(articleId);

    return "redirect:/articles.html";
}
Run Code Online (Sandbox Code Playgroud)

这是服务层

    @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void removeArticle(Integer id) {
    articleDao.removeArticle(id);
}
Run Code Online (Sandbox Code Playgroud)

这是Dao层(我试图找到文章然后删除它)

    public void removeArticle(Integer id) {
            //to get the article
    Article article = (Article) sessionFactory.getCurrentSession().load(
            Article.class, id);
    if …
Run Code Online (Sandbox Code Playgroud)

dao hibernate controller spring-mvc

2
推荐指数
1
解决办法
3947
查看次数

标签 统计

spring-mvc ×2

algorithm ×1

blob ×1

c# ×1

controller ×1

dao ×1

gps ×1

hibernate ×1

multipart ×1