提交 85c3e102 编写于 作者: 7 7wc98#14

Update

上级 adf1c182
......@@ -228,9 +228,17 @@ public class WebController {
String currentStudentId = ((UserDetails) securityContext.getAuthentication().getPrincipal()).getUsername();
Student s = studentRepository.findNameByStudentID(currentStudentId);
model.addAttribute("curUse",s);
long nextId = newsRepository.countAll()+1;
long i=0;
List<News> list = newsRepository.findAll();
for(News l:list){
if(l != null)
{
i++;
}
}
long nextId = i+1;
News news = new News(nextId,title,content);
newsRepository.save(news);
return "/page/BrowseNews";
return "/page/PublishNews";
}
}
......@@ -10,9 +10,6 @@ package com.pyc.campus.dao;
import com.pyc.campus.domain.News;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface NewsRepository extends JpaRepository<News,Long> {
Long countAll();
}
......@@ -169,9 +169,8 @@
</div>
<div id="footer">
<div class="container">
<p>
<span>Campus logo</span>
<span>@2020 御承扬Copyright&copy;2020-05-04</span>
<p style="color: white;text-align: center;">
@2020 御承扬Copyright&copy;2020-05-04
</p>
</div>
</div>
......
......@@ -78,7 +78,7 @@
</div>
<div class="main">
<h1><span th:text="${curUse.getName()}"></span>您好! </h1>
<form class="form-horizontal" name="newsForm" method="post" action="/saveNews" onsubmit="return checkTitleAndContent(newsForm.title, newsForm.content)">
<form class="form-horizontal" name="newsForm" method="post" th:action="@{/saveNews}" action="/saveNews" onsubmit="return checkTitleAndContent(newsForm.title, newsForm.content)">
<table style="text-align: center;width: 450px;height: 300px;border: 1px;">
<tr>
<td style="text-align: center;height: 40px" colspan="2">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册