我想在spring mvc中使用注释方法创建一个示例项目,用户可以通过单击按钮导航到一个页面到另一个页面。我为spring创建了一个新的mvc项目示例
我期待你的帮助先谢谢你
登录。JAVA
package credentials;
public class Login {
private String name;
private String password;
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return password;
}
}
登录控制器。JAVA
package credentials;
import org.apache.tomcat.jdbc.pool.Validator;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class LoginController {
@RequestMapping(value="/login")
public ModelAndView login(){
return new ModelAndView("login","command",new Login());
}
@RequestMapping(value="/calc")
public ModelAndView Add(){
return new ModelAndView("calc","command",new Login());
}
}
登录。jsp
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2>Login here</h2>
<form:form method="POST" action="calc">
<table>
<tr>
<td><form:label path="name">Name</form:label></td>
<td><form:input path="name" /> </td>
</tr>
<tr>
<td><form:label path="password">Password</form:label></td>
<td><form:password path="password"></form:password></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="login" />
</td>
</table>
calc.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form:form method="POST" action="content">
<h2>Add content</h2>
<table>
<tr>
<form:button path="mouse" value="Mouse">Mouse</form:button>
<td>
</tr>
</table>
</form:form>
</body>
</html>
所容纳之物jsp
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2>Submitted Student Information</h2>
</body>
</html>
当点击calc页面上的“鼠标”按钮时,会出现以下错误
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
加上
<form:input path="mouse"/>
单击登录页面中的登录按钮时发生以下错误
HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp at line 16
type Exception report
message An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp at line 16
description The server encountered an internal error that prevented it from fulfilling this request.
例外
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp at line 16
13:
14: <tr>
15: <form:button path="mouse" value="Mouse">Mouse</form:button>
16: <form:input path="mouse"/>
17: <td>
18:
19: </tr>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
org.springframework.beans.NotReadablePropertyException: Invalid property 'mouse' of bean class [credentials.Login]: Bean property 'mouse' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729)
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721)
org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:219)
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:198)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:164)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:151)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:142)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:126)
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspx_meth_form_005finput_005f0(calc_jsp.java:201)
org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspx_meth_form_005fform_005f0(calc_jsp.java:126)
org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspService(calc_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
问题内容: 如何创建以下注释的实例(所有字段均设置为其默认值)。 我试过了,但这似乎不起作用… 问题答案: 您无法创建实例,但至少要获取默认值 然后,可以使用动态代理返回默认值。据我所知,这也是Java本身处理批注的方式。
我感兴趣的是拍摄一个tif图像,并在其中添加一个包含Java文本的层,如果可能的话,最好使用十二只猴子图像库。 我可以从这里调整代码以将文本添加到tif或仅使用文本创建相同大小的新tif,但不能将它们保存为多页tif。例如: Maven公司: 如何从图像和生成的文本图像创建多页tif? 我能够为JPG运行以下代码,但JPG没有层。 非常感谢。
我有一个GATE文档,其字符串如下所示:
在我的项目中,我有一些重构逻辑的公共接口。看起来是这样的: 然后,当我需要编写一些重构时,我用方法实现这个接口,标记类,如组件,Spring-in-loop评估每个接口实现并将其注册到数据库中。但是我们有很多重构(每年有200-300个新的)。很难手动禁用旧的实现,我们在spring上下文中有很多bean。我们可以做些什么吗,例如,使用一些注释-这将在某些条件下禁用组件创建? 例如: 此注释的工作
我是Hibernate的新手,正在尝试学习它。我对@JoinCol列的用法感到困惑。我知道它创建了一个列来关联两个实体。我尝试过的是: 有两个阶级的人和房子 个人阶级有一套与一个家庭有关系的房子 当面授课: 这将在表上创建一个名为的列。 内部课程: 这将在表上再次创建列。但我希望能在表上看到这个专栏。为什么会这样? 我在想@JoinColumn annotation会在表上创建一个连接列,这就是我
我需要在一个页面上创建多个二维码。 我使用的图书馆 https://larsjung.de/jquery-qrcode/ 我用这样一个代码打印了多个,但二维码创造的价值是“无文本”。 它生成一个条形码与下面的代码,但不幸的是,我有麻烦创建多个条形码。 null null