- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
The error I am getting:
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name: Apache Tomcat/9.0.27
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Oct 7 2019 09:57:22 UTC
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.27.0
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Linux
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 5.0.0-32-generic
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Private Build
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: /home/sudarshan/Documents/workspace-spring-tool-suite-4-
4.4.1.RELEASE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: /home/sudarshan/Downloads/apache-tomcat-9.0.27
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/home/sudarshan/Documents/workspace-spring-
tool-suite-4-4.4.1.RELEASE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/home/sudarshan/Downloads/apache-tomcat-9.0.27
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/home/sudarshan/Documents/workspace-spring-tool-
suite-4-4.4.1.RELEASE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/home/sudarshan/Downloads/apache-tomcat-
9.0.27/endorsed
Nov 01, 2019 9:51:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Nov 01, 2019 9:51:04 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the java.library.path:
[/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-
gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
Nov 01, 2019 9:51:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-2016"]
Nov 01, 2019 9:51:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Nov 01, 2019 9:51:05 AM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [607] milliseconds
Nov 01, 2019 9:51:05 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Nov 01, 2019 9:51:05 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.27]
Nov 01, 2019 9:51:06 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Nov 01, 2019 9:51:06 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for
this logger for a complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Nov 01, 2019 9:51:06 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'ds'
Nov 01, 2019 9:51:06 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Initializing Servlet 'ds'
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
`com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual
loading of the driver class is generally unnecessary.
Nov 01, 2019 9:51:07 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Completed initialization in 746 ms
Nov 01, 2019 9:51:08 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Nov 01, 2019 9:51:08 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for
this logger for a complete list of JARs that were scanned but no TLDs were found in them.
Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Nov 01, 2019 9:51:08 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'ds'
Nov 01, 2019 9:51:08 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Initializing Servlet 'ds'
Nov 01, 2019 9:51:08 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Completed initialization in 612 ms
Nov 01, 2019 9:51:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-2016"]
Nov 01, 2019 9:51:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Nov 01, 2019 9:51:08 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in [3,765] milliseconds
Nov 01, 2019 9:51:09 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping for GET /StudentCurd/
Student.java class containing setters and getters:
package StudentCurd;
public class Student
{
int id;
String name;
String email;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
StudentController.java class:
package StudentCurd;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class StudentController
{
@Autowired
StudentDao dao;
@RequestMapping("/studentform")
public String showForm(Model m)
{
m.addAttribute("command", new Student());
return "studentform";
}
@RequestMapping(value="/save",method = RequestMethod.POST)
public String save(@ModelAttribute("s") Student s){
dao.save(s);
return "redirect:/viewemp"; //will redirect to viewemp request mapping
}
@RequestMapping("/viewemp")
public String viewemp(Model m){
List<Student> list=dao.getStudents();
m.addAttribute("list",list);
return "viewemp";
}
@RequestMapping(value="/editemp/{id}")
public String edit(@PathVariable int id, Model m){
Student s=dao.getStudentById(id);
m.addAttribute("command",s);
return "empeditform";
}
@RequestMapping(value="/editsave",method = RequestMethod.POST)
public String editsave(@ModelAttribute("s") Student s){
dao.update(s);
return "redirect:/viewemp";
}
@RequestMapping(value="/deleteemp/{id}",method = RequestMethod.GET)
public String delete(@PathVariable int id){
dao.delete(id);
return "redirect:/viewemp";
}
}
StudentDao.java to interact with database:
package StudentCurd;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import StudentCurd.Student;
public class StudentDao
{
JdbcTemplate template;
public void setTemplate(JdbcTemplate template) {
this.template = template;
}
public int save(Student s){
String sql="insert into student(id,name,email)
values('"+s.getId()+"',"+s.getName()+",'"+s.getEmail()+"')";
return template.update(sql);
}
public int update(Student s){
String sql="update student set id='"+s.getId()+"',
name="+s.getName()+",email='"+s.getEmail()+"' where id="+s.getId()+"";
return template.update(sql);
}
public int delete(int id){
String sql="delete from student where id="+id+"";
return template.update(sql);
}
public Student getStudentById(int id){
String sql="select * from student where id=?";
return template.queryForObject(sql, new Object[]{id},new BeanPropertyRowMapper<Student>
(Student.class));
}
public List<Student> getStudents(){
return template.query("select * from student",new RowMapper<Student>(){
public Student mapRow(ResultSet rs, int row) throws SQLException {
Student s=new Student();
s.setId(rs.getInt(1));
s.setName(rs.getString(2));
s.setEmail(rs.getString(3));
return s;
}
});
}
}
web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
`xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-
app_3_0.xsd" id="WebApp_ID" version="3.0">`
<display-name>StudentMvc</display-name>
<servlet>
<servlet-name>ds</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ds</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
ds-servlet.xml bean configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="StudentCurd" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/userdb"></property>
<property name="username" value="root"></property>
<property name="password" value="password"></property>
</bean>
<bean id="jt" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="ds"></property>
</bean>
<bean id="dao" class="StudentCurd.StudentDao">
<property name="template" ref="jt"></property>
</bean>
</beans>
index.jsp file:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="studentform">Add Student</a>
<a href="viewstudent">View Students</a>
</body>
</html>
studenteditform.jsp file:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Edit Employee</h1>
<form:form method="POST" action="/StudentCurd/editsave">
<table >
<tr>
<td></td>
<td><form:hidden path="idh" /></td>
</tr>
<tr>
<td>Id : </td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td>Name :</td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td>Email :</td>
<td><form:input path="email" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Edit Save" /></td>
</tr>
</table>
</form:form>
studentform.jsp file
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Add New Student</h1>
<form:form method="post" action="save">
<table >
<tr>
<td>Id : </td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td>Name :</td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td>Email :</td>
<td><form:input path="email" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save" /></td>
</tr>
</table>
</form:form>
viewstudent.jsp file:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Student List</h1>
<table border="2" width="70%" cellpadding="2">
<tr><th>Id</th><th>Name</th><th>Email</th><th>Edit</th><th>Delete</th></tr>
<c:forEach var="s" items="${list}">
<tr>
<td>${s.id}</td>
<td>${s.name}</td>
<td>${s.email}</td>
<td><a href="editemp/${emp.id}">Edit</a></td>
<td><a href="deleteemp/${emp.id}">Delete</a></td>
</tr>
</c:forEach>
</table>
<br/>
<a href="studentform">Add New Student</a>
there are some solutions listed but those are regarding http and url, I tried those also but did't find any solution
最佳答案
你的错误告诉你问题是什么。您的 Controller 中没有到“/StudentCurd/”的映射。
更可能的问题是您认为您的上下文路径是/StudentCurd (您的包的名称),但事实并非如此。您应该只访问“/editsave”,而不是尝试访问“/StudentCurd/editsave”。
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<h1>Edit Employee</h1>
<form:form method="POST" action="/StudentCurd/editsave"> <-- remove /StudentCurd
<table >
<tr>
<td></td>
<td><form:hidden path="idh" /></td>
</tr>
<tr>
<td>Id : </td>
<td><form:input path="id" /></td>
</tr>
<tr>
<td>Name :</td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td>Email :</td>
<td><form:input path="email" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Edit Save" /></td>
</tr>
</table>
</form:form>
编辑:
如果您的上下文路径位于/StudentCurd(您将 Web 应用程序部署在/StudentCurd 而不是 ROOT),那么您会收到此错误,因为您没有“/”的映射。您应该有一个基本索引模板 (index.jsp),它充当您的主页,映射到“/”。如果您尝试访问“/StudentCurd/studentform”,它应该可以工作,前提是您的上下文路径是/StudentCurd而不是ROOT(在这种情况下您将只访问“/studentform”)
在你的 Controller 中:
@RequestMapping("/")
public String home() {
return "index";
}
类似这样的事情。如果您希望学生表单成为主页,只需更改映射即可:
@RequestMapping("/")
public String showForm(Model m)
{
m.addAttribute("command", new Student());
return "studentform";
}
关于java - 警告 : No mapping for GET/StudentCurd/(HTTP Status 404 – Not Found) I have tried all the solutions but not able to sole this, 所以再次询问:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58654258/
我对文档有点困惑。请纠正我。 git 状态- 显示当前本地工作目录状态 git status -u- 显示未跟踪的文件(也是本地的) git 状态 -uno- 不显示未跟踪的文件(也是本地的)?? 后
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有以下 JavaScript 代码: alert(data.status); data 是一个 JSON 对象,其字段之一是 status ( bool 字段)。 当JSON.stringify(d
我在验证表单时遇到此错误,如何解决它。 代码: app.post('/',[ check('username','Error occured in Username').trim().isEmai
我正在开发一个使用 fork() exec() wait() 的 C 程序。第一个进程有以下代码: int main(int argc, const char * argv[]) { // inser
我想在 git status 上运行 linter,但是似乎没有 pre-status 和 post-status Hook 。 如何给 git 添加一个钩子(Hook)? fine docs对此事保
我需要获取所有 current_user.friends 状态,然后按 created_at 对它们进行排序。 class User a.created_at } end current_user.
我在 Eloquent 中使用 orWhere 时遇到问题。 我有一个团队,这个团队有一些资料。我想获取状态 = 1 或状态 = 2 的所有配置文件。但我无法让它工作。 我的代码是这样的: $prof
http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT 根据这
我们在 IIS 6.0 上托管 WCF 服务的服务器之一上观察到以下行为: IIS 日志显示所用时间的值较高 (> 100000) HTTP 状态码是 200 sc-win32-status 代码显示
在 Dynamics CRM 中,潜在客户实体同时具有状态和状态原因。使用 API 我可以获得所有状态原因。我被绊倒的地方是当我的用户选择状态原因时我想倒退并找出哪个状态与所选状态原因相关联。 以下是
我很好奇返回响应和仅创建响应的区别。 我见过大量使用 return res.status(xxx).json(x) 的代码示例和res.status(xxx).json(x) . 谁能详细解释一下两者
文档并没有真正说明 status 是什么。 status 到底是什么? http://man7.org/linux/man-pages/man2/exit_group.2.html 最佳答案 来自ex
An earlier question导致了一些关于如何检查 Git 存储库是否包含脏索引或未跟踪文件的想法。我从那次讨论中采纳的答案如下: #!/bin/sh exit $(git status -
ECSHOP出现 XMlHttpRequest status:[500] Unknow status 这个错误 把/admin/templates/top.htm 这个文件中{insert_scr
我有以下代码用于通过 Twitter4J 获取推文: List statuses; Paging paging = new Paging(1, LIMIT); statuses = twitter.g
非常不言自明。我正在制作一个脚本并且遇到了被使用和解析的情况,但它们的输出似乎总是完全相同。 最佳答案 git status --branch --porcelain "显示分支的状态(ahead,
我有一张表,上面有如下记录 表A subid clickid status datetime 1 123 low 2018-07-24 20:20:44 2 123
如果确实缺少资源,我的 API 将返回以下内容 { "code": 404, "message": "HTTP 404 Not Found" } 当我使用代码 Response.sta
我是一名优秀的程序员,十分优秀!