- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 spring mvc 3.2 + jdbc 项目中遇到此错误。
“HTTP 状态 500 - java.lang.IllegalStateException:BindingResult 和 bean 名称“app”的普通目标对象都不能用作请求属性”
我看到我的人问过这个问题。我已经看完了答案。但两者都对我有用。请帮我 。提前致谢。
这是我的 HomeController.java:-
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import MediatoPrima.Beans.Application;
import MediatoPrima.services.ApplicationService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class MediatoPrimaController {
@Autowired
ApplicationService applicationService;
@RequestMapping("/AppMgt_AddnewApp")
public ModelAndView registerUser(@ModelAttribute("application") Application app) {
List<String> LobList = new ArrayList<String>();
LobList.add("Asia");
LobList.add("Australia");
LobList.add("America");
LobList.add("Europe");
Map<String, List> map = new HashMap<String, List>();
map.put("cityList", LobList);
return new ModelAndView("AppMgt_AddnewApp", "map", map);
}
@RequestMapping("/insert")
public String inserData(@ModelAttribute Application application) {
if (application != null)
applicationService.addnewApp(application);
return "redirect:/AppManagment";
}
}
这是我的 ApMgt_AddnewApp.jsp这是项目的欢迎文件
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="css/Appmang.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>:: New Application < title>
</head>
<body>
<div id="content_page_for_userHome"><br>
<div id="divForSideNavigation">
<center>
<ul>
<li><a href="AppMgt_AddnewApp.html"><img src="Images/add.png"
border="0" /><br>
New Application</a></li>
</ul>
</center>
</div>
<div id="addnewBox_app"><form:form action="AddnewApp"
method="post" modelAttribute="application">
<center><c:url var="action" value="/AppMgt_AddnewApp.html"></c:url>
<form:form method="post" action="/insert" modelAttribute="app">
<table>
<tr align="left">
<td>APPID</td>
<td><form:input path="id" readonly="true" size="8" disabled="true" id="txt"/>
<form:hidden path="id" /></td>
<td>*</td>
</tr>
<tr align="left">
<td>APPCODE</td>
<td><form:input path="AppCode" /></td>
<td>*</td>
</tr>
<tr align="left">
<td>APPLICATION</td>
<td><form:input path="Appname" /></td>
<td>*</td>
</tr>
<tr align="left">
<td>LOB</td>
<td><form:input path="lob" /></td>
<td>*</td>
</tr>
<tr align="left">
<td>geog</td>
<td><form:input path="geo" /></td>
<td>*</td>
</tr>
<tr align="left">
<td>DESC</td>
<td><form:input path="desc" /></td>
</tr>
<tr align="left">
<td colspan="2" align="center"><input type="submit" value="Save" class="Appbutton"/> <input type="button"
value="Cancel" class="Appbutton" /></td>
</tr>
</table>
</form:form></center>
</form:form></div>
</div>
</body>
</html>
这是我的 spring-servlet.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<!-- telling container to take care of annotations stuff -->
<context:annotation-config />
<!-- declaring base package -->
<context:component-scan base-package="com" />
<!-- adding view resolver to show jsp's on browser -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- declare beans -->
<bean id="ApplicationDao" class="com.Dao.ApplicationDaoImpl" />
<bean id="ApplicationService"
class="com.services.ApplicationServiceImpl" />
<!-- declare datasource bean -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@172.21.51.32:1521:sid" />
<property name="username" value="uname" />
<property name="password" value="pwd" />
</bean>
</beans>
this is my 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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>SpringJDBCTemplate</display-name>
<welcome-file-list>
<welcome-file>AppMgt_AddnewApp.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
and these are the jars am using.
![These are the jars am using.][1]
最佳答案
错误是,在jsp中它应该是modelAttribute="application"
:
<form:form method="post" action="/insert" modelAttribute="application">
PS:最好在@RequestMapping
中添加method="POST"
关于java - HTTP 状态 500 - java.lang.IllegalStateException : Neither BindingResult nor plain target object for bean name 'app' available as request attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25363403/
文件 A 包含 hash:plain文件 B 包含用户名:hash需要的输出用户名:plain有什么办法可以在 shell 中做到这一点吗? 最佳答案 使用带有cut的命令替换: echo $(cut
我可以看到来自邮件服务器的许多 ehlo 命令回显,如下所示: 我想知道“250-AUTH LOGIN PLAIN”和“250-AUTH=LOGIN PLAIN”有什么区别?谢谢 最佳答案 它们的意思
我试图了解两者之间的区别: 一个“普通” elasticsearch查询,它将与术语查询匹配,并返回一定数量的匹配。 和一个过滤的查询(因此使用过滤器)将返回相同的匹配数。 这是术语查询: GET _
我正在开发一个可以接收文件 url 的应用程序,并且应该根据文件类型(音频、视频、图像)做不同的事情。所以我以这种方式获取文件的内容类型: URLConnection connection = url
Nodemailer 使用完全相同的配置正常工作了几个月。 var smtpTransport = nodemailer.createTransport({ service: "Zoho", auth
我使用的是来自非正统终端的gradle,因此Gradle的传统“漂亮”输出不起作用。 有什么方法可以在〜/ .gradle / gradle.properties中指定每个gradle命令都应使用--
在 Julia 中,你不能存储这样的字符串: str = "\mwe" 因为有一个反斜杠。因此,以下内容可以帮助您防止这种情况发生: str = "\\mwe" "$,\n" 和许多其他符号也会发生同
我需要将 data.frame 对象“转换”为纯文本(如 print 输出到控制台。 到目前为止,我创建了以下函数(使用 stringr 包),但我想知道是否存在已实现的函数或更有效的方法: toSt
在 Julia 中,你不能存储这样的字符串: str = "\mwe" 因为有一个反斜杠。因此,以下内容可以帮助您防止这种情况发生: str = "\\mwe" "$,\n" 和许多其他符号也会发生同
我正在编写一个登录面板来访问管理面板。数据(用户名和密码)存储在 MySQL 数据库(类型:InnoDB)中。在表中查看密码以纯文本形式存储,在字段密码中我有:{普通}密码。 调整我已有的代码时,我遇
我正在尝试使用类名 Plain Javascript 获取第一个子元素。 我正在尝试编写自己的表单验证并尝试附加错误消息并将其删除。如果错误消息已经存在,则不要追加。 如果您帮助我完成第一部分,为 c
问题:使元组的元组“简单”的最佳方法是什么?例如。一维。 案例 1 template auto process_field(Field&& field){ // or another std
我正在编写一个 Web 应用程序 API,当有人访问 URL 时,它会返回文本数据。我将内容类型设置为“文本/纯文本”,但是当我使用 Chrome 访问它时,它会下载一个包含信息的文件,而不是显示它。
我尝试将文本粘贴到多个字段中,但只清除了第一个元素的格式,而不是第二个元素等。 我发现了这个问题 https://stackoverflow.com/a/12028136/3955607这工作正常,但
我有一个查询,它使用聚合函数将值的 maximum absolute 分配给表中的另一列。问题是查询完成时间需要花费大量时间(大约加起来 10-15 秒)。这是查询的样子: UPDATE calcul
我在尝试使用 text/plain 时收到以下响应: { "type": "https://tools.ietf.org/html/rfc7231#section-6.5.13", "
我想做的是- For Clients to Broker communication - use OAUTHBEARER authentication For Broker to Broker com
我了解 th:if 如何用于 html 模板,但是当您期望纯文本(用例:纯文本电子邮件模板)时,我没有找到有关如何执行此操作的任何线索。 到目前为止,我尝试过: Dear [[${contact
我有以下代码: NSURL *URL = [NSURL URLWithString:[@"some-address"]]; NSMutableURLRequest *request = [NSMuta
关闭。这个问题需要多问focused 。目前不接受答案。 已关闭10 年前。 已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 有人可以用简单的
我是一名优秀的程序员,十分优秀!