Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
using spring-boot i m trying to post image but i got
org.thymeleaf.exceptions.TemplateInputException
entity class
@Entity
@Table(name="image")
public class ImageEntity {
@Column(name="imageId")
private String imageId;
@Column(name="imageName")
private String imageName;
@Column(name="type")
private String type;
/*@Column(name="size")
private long size;*/
@Column(name="imagepath")
private String path;
public ImageEntity(String imageName, String type, String path) {
super();
this.imageName = imageName;
this.type = type;
//this.size = size;
this.path = path;
Controller Class
@Controller
public class ImgContr {
public static final Logger logger =LoggerFactory.getLogger(ImgContr.class);
@Autowired
public ImgService imgService;
@PostMapping("/addImage")
public ImageEntity saveImage(@RequestBody ImageEntity imgent, RedirectAttributes redirectAttributes) throws Exception
return imgService.saveImage(imgent );
Domain Service
@Service
public class ImgService {
@Autowired
public ImageDao imageDao;
public ImageEntity saveImage(ImageEntity imgent) {
ImageEntity imgEngDom=new ImageEntity();
imgEngDom.setImageId(imgent.getImageId());
imgEngDom.setImageName( imgent.getImageName());
imgEngDom.setPath(imgent.getPath());
//imgEngDom.setSize(imgent.getSize());
imgEngDom.setType(imgent.getType());
return imageDao.saveImage(imgEngDom);
ImageDAO.java
@Repository
public class ImageDao {
@PersistenceContext
private EntityManager entityManager;
@Autowired
SessionFactory sessionFactory;
public ImageEntity saveImage(ImageEntity imgEngDom) {
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
session.save(imgEngDom);
session.getTransaction().commit();
} catch (Exception e) {
session.getTransaction().rollback();
} finally {
session.close();
return imgEngDom;
Payload Request.
"imageName": "Divya",
"type" : "jpg",
"path": " C:/Users/admin/Desktop"
//if i try to post image like this below in postman i got error
Error
"timestamp": 1548408353973,
"status": 500,
"error": "Internal Server Error",
"exception": "org.thymeleaf.exceptions.TemplateInputException",
"message": "Error resolving template \"addImage\", template might not
exist or might not be accessible by any of the configured Template
Resolvers",
"path": "/addImage"
I am new to springboot
where i m wrong. Help me.
–
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.