JavaWeb project under the Eclipse jsp files referenced in the path leading to the problem can not be read local resources

All paths are set up the way and path set by reference in the same local images, details settings, click here . Quoted local image path, said arrangement is done at the server path settings under the eclipse, the link to the webapps directory under the tomcat ROOT files, but links to any folder can be , as long as the relative path set, according to the directory path can be found there is no problem, it will hit the links folder within a file is not a problem in this project file. The best resource to be read are placed in a folder, so do not set many times. Figure:

Use examples provided above:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <%@ page import="java.*" %>
 4 <!DOCTYPE html>
 5 <html>
 6 <head>
 7 <meta charset="UTF-8">
 8 <title>例</title>
 9 </head>
10 <body bgcolor=cyan><font size=2>
11     <form action="example3_5_receive.jsp" method=post name=form>
12       <br>背景音乐:<input type="radio" name="R" value="on" >打开 
13           <input type="radio" name="R" value="off" checked="default">关闭 
14        <br> favorite team:     
 15            <= the INPUT of the type "the CheckBox" name = "Item" value = "Inter Milan"> Inter Milan
 16            <= the INPUT of the type "the CheckBox" name = "Item" value = "AC Milan "> AC Milan
 17        <br> <the INPUT of the type =" the CheckBox "name =" Item "value =" Roma "> Roma
 18            <= the INPUT of the type" the CheckBox "name =" Item "value =" Munich "> Munich
 19            <the INPUT of the type =" hidden "value =" I am a fan, but will not play "name =" Secret ">
 20        <br> <the INPUT of the type =" the submit "value =" submit "name ="
submit">
21           <input type="reset" value="重置" >
22    </form>    
23 </font></body>
24 </html>
View Code

 This is not the top choice to see the interface, the processing section in the lower half:

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <%! public String handleStr(String s) {
 4        try {  byte [] bb= s.getBytes("iso-8859-1");
 5               s = new String(bb);
 6        }
 7        catch(Exception exp){}
 8        return s;
 9     }
10 %>
11 <!DOCTYPE html>
12 <html>
13 <head>
14 <meta charset="UTF-8">
15<title> processing </ title>
 16 </ head>
 . 17 <body> <font size = 2>
 18 is     <%  
 . 19         String OnOrOff request.getParameter = ( "R & lt");              // get the value submitted by the radio 
20 is         String = secretMess request.getParameter ( "Secret");      // get the value of hidden filed 
21 is         String itemName [] = request.getParameterValues ( "Item"); // get the value submitted checkbox 
22 is         Out.println ( "<P> is open bACKGROUND Music: "+ OnOrOff);
 23         out.println (" <the p-> your favorite team: " );
24-         IF (itemName == null ) {
 25            out.print ( "a do not like.");
26        } 
27        else {
28          for(int k=0;k<itemName.length;k++) {
29            out.println(" "+handleStr(itemName[k]));
30          }
31        }
32        out.println("<P> 你提交的隐藏信息:"+handleStr(secretMess));
33        if(onOrOff.equals("on")) {
34    %>    <embed src='/sound/back.mp3' loop ="-1" autostart=true width=0 height=0/>
35    <%  } 
36    %>
37 </font></body>
38 </html>

34 is a link line /sound/back.mp3  because the path is set in front Path /, sound and audio files in the folder, so that such writing. If the path Path to / upload, it is /upload/sound/back.mp3. Be sure to remember to add the front to set a good path name Path!

 

Guess you like

Origin www.cnblogs.com/Anber82/p/12612749.html