Tag Archives: JSP

[Solved] Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred.

Error: could not create the Java virtual machine.
error: a fatal exception has occurred.program will exit

After I reinstalled eclipse, Tomcat reported this error when running JSP
Google has various solutions, some say Java, some say JDK, and some say Tomcat. They can’t use

Solution: just reset a workspace

Using JSTL to traverse the list set reports an error

Use JSTL to report an error when traversing the list set

javax.el.PropertyNotFoundException: Property [department] not found on type [com.studying.model.Employee]

However, the Department attribute in the data transmitted from the back end has a value

Error reason

After careful search, it is found that the set/get method of attribute Department has been forgotten in the employee class

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

SSM custom 404 and 500 error reporting interface

SSM custom 404 and 500 error reporting interface

1. In web.xml Configuration 2, test 404 error

1. In web.xml Medium configuration

 <!--Replace the 400 and 500 error message screens-->
  <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/error/404.jsp</location>
  </error-page>
  <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/error/500.jsp</location>
  </error-page>

2. Test 404 error

As shown in the figure below, is the effect much more comfortable than a pile of newspapers.

org.apache.jasper.JasperException: Unsupported encoding:

org.apache.jasper .JasperException: Unsupported encoding: 

org.apache.jasper . compiler.DefaultErrorHandler.jspError ( DefaultErrorHandler.java:51 )

org.apache.jasper . compiler.ErrorDispatcher.dispatch ( ErrorDispatcher.java:409 )

org.apache.jasper . compiler.ErrorDispatcher.jspError ( ErrorDispatcher.java:116 )

org.apache.jasper . compiler.JspUtil.getReader ( JspUtil.java:1093 )

org.apache.jasper . compiler.ParserController.doParse ( ParserController.java:250 )

The reason for throwing this exception is that there is a problem in the encoding settings of the JSP page

<%@ page language=”java” import=” java.util .*” pageEncoding=””%>

Here, the value of pageencoding is empty, which cannot be recognized by the server. Even if there is one more space, the server will not recognize it.

& lt;% @ page contenttype = “text/HTML; charset = GB2312″% & gt; the charset here has an extra space, so this exception should be thrown.

After eclipse eclipse eclipse imports the correct project, an error is reported in XML and other files

I use eclipse ide to import a correct project. Some XML configuration files and JSP pages report errors. Click in to view the specific errors. XML files report errors in some header files, and JSP functions. But others did not report mistakes.

This is because the files we wrote are not written in strict accordance with the relevant rules of J2EE, but the operation will not make mistakes, as long as we do not let the project configuration select these.

resolvent:

Step 1: Project Explorer (if you don’t have this window, you can select an inverted triangle sign in the eclipse toolbar – & gt; window – & gt; show view – & gt; Project Explorer) – & gt; select the customize view (as shown in Figure 1) – & gt; content tab – & gt; and remove some J2EE and the last option (as shown in Figure 2 – available customization).

Figure 1

Figure 2

Step 2: Eclipse toolbar – & gt; window – & gt; preferences – & gt; validation – & gt; click the “disable all” button – & gt; OK/apply (as shown in the figure)

Step 3: clean the project and rebuild it.

After eclipse Eclispe imports the correct project, XML appears

Original text: http://blog.csdn.net/u013147600/article/details/47102971

MySQL:Foreign key fails with error Error Code: 1452.

Today in MySQL, we add foreign keys to A table, the type is int, the name is not wrong, I temporarily want to add foreign keys to Table A table B, that is, the foreign keys in table A are associated with the primary key in table B.
NavigateSQL, however, always saves an operation with an error:
Foreign key fails with error error Code: 1452. Cannot add or update a child row: a Foreign key constraint fails: XXX.< result 2…

Go through Google and solve from StackOverflow!

The original B table I created temporarily had no data. When I added data to B table, I reported the same error again.

Originally, table A associated table B primary key field value, and table B value inconsistent, I manually changed the consistent “content consistent” can be!

StachOverflow:
http://stackoverflow.com/questions/7354032/foreign-key-fails-with-error-error-code-1452-cannot-add-or-update-a-child-row

Record here for accumulation!

About writing [if] and [else] statements in JSP, Syntax error on token “else”, delete this token

A article is reproduced here: https://blog.csdn.net/sinat_37062120/article/details/79208949
Insert Java code into the JSP

<%if (***)%>
<%=***%>
<%else %>
<%=***%>

Error in the “else” in the third line
Syntax error on token “else”, delete this token

else must be followed by if. This error indicates that if
solution is not found:
add parentheses. Note that the “} “of if must be written inside the” else”

<%if (***) {%>
<%=***%>
<%} else {%>
<%=***%>
<%}%>

 

(springmvc) Failed to load resource: the server responded with a status of 404 (Not Found)

Today, I plan to upload the plug-in function I wrote to Github, create a new Java project, which USES the Spring MVC framework, and then debug the page when I found that I could not find the static resource file, as shown in the figure below:

So I checked the path of the page resource on the JSP at the first time:

<link rel="stylesheet" type="text/css" href="css/amazeui.min.css">
	<link rel="stylesheet" type="text/css" href="css/amazeui.cropper.css">
	<link rel="stylesheet" type="text/css" href="css/custom_up_img.css">

After confirmation, the path was found to be correct:

Friends can refer to my file path, if the path is wrong, then you can change the path to solve the problem.
Then I go on to my question, which is obviously not a path problem, so what is the reason why the page cannot find the static file?I finally saw the console output the following message:

Interpretation, i.e., when the request distribution, did not find “/ ScreenshotForUpload/CSS/amazeui. Min. CSS” mapping (No mapping found for…) “And I found out what the problem was. It turns out that spring MVC is blocking the request of a page to a static resource, but your controller does not have the mapping of this path, so the page request to a static resource file is not issued correctly. So how do you solve this problem?The following methods are given for reference:
Solutions:
1. Adopt & lt; mvc:default-servlet-handler /> . Add the following sentence to the SPRING MVC XML configuration file: < mvc:default-servlet-handler /> . As shown in the figure below:

After joining, Spring MVC will screen the URL entering the DispatcherServlet, and if a request for static resources is found, the request will be processed by the default Servlet of the Web application server, and if it is not a static resource, then the DispatcherServlet will continue to process. This method is the fastest.
2. Use & lt; mvc:resources /> . You can use < mvc:resources /> , and put the static resources in the Web-inF directory (or wherever you like), then add the following configuration in springMVC-Servlet:

<mvc:resources location="/File floder" mapping="/mapping path"/>

Fill in the path according to the actual situation.
3. In the web.xml file, change the blocking path of Spring MVC to/SpringMVC /* (” SpringMVC “can be replaced with your preferred path), as shown in the figure below
thus distinguishes “requests to Spring MVC” from “requests to static resource files”, but has the disadvantage that all your MVC requests must start with “/ SpringMVC “.
The problem that the static resource file cannot be found caused by Spring MVC can be said to be relatively secret. Novices may be unable to find the root of the problem for a while. I hope this article can provide you with help!