Tag Archives: path

Using common file upload to upload files in SSH project

Today, the project used to upload. What I store in my database is the URL of the file, so I have to do some processing in the background. I have written several times before uploading, and I feel that the amount of code is too large. Today, I searched the Internet, and it will be much easier to upload with common file upload. After groping for an afternoon, I finally got it done. The background code is as follows

//The uploaded file
private File upload;
//file name and type
private String uploadContentType;
private String uploadFileName;
/*This is the variable to be written in the action, you must write it, otherwise it will be very troublesome, Struts2 will automatically assign the file to be uploaded, the file name, type, etc.*/

/// The following is the processing method
public String uploadStaffImage() throws Exception{
	//Take the file name and path, rename the file name with uuid to prevent Chinese mess
	String fileName = UUID.randomUUID().toString();
        //intercept file type
        String fileType = this.uploadFileName.substring(this.uploadFileName.lastIndexOf("."), this.uploadFileName.length());
        //New file name
        String file = fileName + fileType;
        // My directory is under "StaffImg" folder
        String path = request.getSession().getServletContext().getRealPath("/StaffImg");
	InputStream is = new FileInputStream(getUpload());  
        //Create an output stream to generate a new file  
        OutputStream os = new FileOutputStream(path + "//" + file);  
        //write disk 
        IOUtils.copy(is, os);
        os.flush();  
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(os);
        //Update the URL in the database
        String imgURL = "StaffImg/"+file;
        this.staffFileUpLoadService.updataStaffImgURL(this.staffId, imgURL);
	return SUCCESS;
}

A total of 13 lines of code, compared to the previous written to be a lot more concise, method use is relatively simple.

This method can only upload a single file. If you upload in batches, the idea is the same, and you should add a loop in the outer layer
instead

[solution] LD: warning: directory not found for option

In the process of IOS development, this problem is easy to be confused. Let’s have a break today.

Problems and Solutions

In short, there are two aspects to this problem.

The error is as follows, which means that it is an exception when querying Library .

"directory not found for option '-L/..."

resolvent:

Project – & gt; targets – & gt; build setting – & gt; library search paths

Delete the path inside

The error is as follows, which means that it is an exception when querying framework .

"directory not found for option '-F/..."

resolvent:

Project – & gt; targets – & gt; build setting – & gt; framework search paths

Delete the path inside

OK, it’s done.

The above problems have been solved. If you want to know more, you can continue to look down.

explain

Briefly speaking, library search paths and framework search paths .

Framework Search Paths

The explanation that can be found in official documents is as follows:

Locating Frameworks in Non-Standard Directories

If your project links to frameworks that are not included in any of the standard locations, you must explicitly specify the location of that framework before Xcode can locate its header files. To specify the location of such a framework, add the directory containing the framework to the “Framework Search Paths” option of your Xcode project. Xcode passes this list of directories to the compiler and linker, which both use the list to search for the framework resources.

Note: The standard locations for frameworks are the /System/Library/Frameworks directory and the /Library/Frameworks directory on the local system.

If the frameworks you refer to are not in standard locations, you need to set “framework search paths” in the configuration file of the project to specify search paths for compilers and linkers.

Library Search Paths

As for “library search paths”, there is no decent official document, but the content should be similar, but one is used to search framework , and the other is used to search Library .

Although it is said that, what is library and what is framework are still very vague.

However, we found some blogs to illustrate this problem, which are quoted below.

quote

Search paths settings in IOS development

In the development of IOS, we often encounter some path settings, such as the introduction of Baidu map SDK, copying projects to other computers, or reporting the error of library not found when multiple people develop at the same time, or introducing a third-party library, such as asihttprequest / retableview often reporting ? Include & lt; & gt; error, so we need to configure some search paths.

Framework/Library Search Paths

1、Framework Search Paths

The search path of the framework (. Framework bundles ) attached to the project is not widely used in IOS development. Generally, the framework built in the system is used for IOS development.

2、Library Search Paths

Xcode will automatically set the search path of the. A file to be dragged to the third-party library (. A files ) in the project. In order to facilitate transplantation or multi person collaborative development, it will usually be manually set.

For example, we will set the SDK of Baidu map as follows:

$(SRCROOT)/../libs/Release$(EFFECTIVE_ PLATFORM_ Name) , where $(srcroot) macro represents your project file directory, $(effective) _ PLATFORM_ Name) macro represents whether the current configuration is OS or simulator

Header Search Path

1. C / C + + header file reference

In C / C + +, include is a mutation instruction. When compiling, the compiler will replace the relative path with the absolute path. Therefore, the absolute path of the header file is equal to the search path + relative path.

(1) ? Include & lt; iostream. H & gt; : refers to the header file under the compiler’s class library path

(2) ? Include "hello. H" : the header file that refers to the relative path of the project directory

2、(User) Header Search Path

(1) header search path refers to the search path of the header file.

(2) User header search paths refers to the search path of user-defined header files

3、Always Search User Paths

If always search user paths is set to Yes , the compiler will first search the path configured by User header search paths . In this case, ? Include & lt; string. H & gt; , User header search paths the files under the search directory will cover the header files of the system.

reference material

    search paths settings in IOS development, IOS: clarify different search paths, IOS developer Library – including frameworks

The solution of undefined reference to error

Chen Yunwen

 

When compiling programs under Linux, we often encounter “undefined reference to XXX” error,

Here is a summary of some possible reasons and solutions for those in need:

 

Speaking of undefined reference error, let’s first mention the link rules of Linux GCC

 

The search order of links is as follows:

 

    – L to find the path specified by the environment variable library from left to right_ Path, use the ‘:’ partition to find / etc from left to right/ ld.so.conf The specified path order is / lib and / usr / lib (64 bit is / lib64 and / usr / lib64)

Search order of dynamic library calls:

 

The path specified by the – rpath parameter of

    LD is the path specified by the LD script that is written dead in the code_ LIBRARY_ Path / etc/ ld.so.conf The specified paths / lib and / usr / lib (64 bit is / lib64 and / usr / lib64)
are

In general, we use the – L method to specify the search path when linking, and use LD when calling dynamic link library_ LIBRARY_ Path to specify the link path

Another problem to note is that as long as the first one is found, it will be returned, and the later ones will not be found. For example, – L. / a – L. / B – LX has libx in a, libx. A and libx. A in B libx.so In this case, libx. A in. / a will be used instead of following the principle of dynamic library priority, because. / A is found first and there is no dynamic inventory with the same name in

 

 

For dynamic link library, the actual symbol positioning is carried out at run time. When compiling. So, if the library it needs is not associated with it, such as libx.so You need to use uldict, But forget to compile libx.so Add – luldit when compiling libx.so I won’t make a mistake when I’m here, because at this time libx.so It is considered as a library, in which there are some symbols that do not know the specific implementation, which are legal and can be specified at runtime or when compiling other binary programs

If G + + – lpath – LX is used The linker will find that the required uldict symbol table can not be found and report an error. However, if the program is loaded in dlopen mode, the program will run directly in this place and report an error because it is in runtime. Another case is that an external interface has been declared and defined in the dynamic library, but it has forgotten to implement it. At this time, the Similar mistakes can occur

If such an error is reported in the runtime, we should pay attention to whether it is due to the fact that some libraries are not linked or some interfaces are not implemented

 

 

With the above foundation, it is not difficult to see that the reasons for the undefined reference error are as follows:

    no corresponding library (. O /. A /. So) uses the entity defined in the library, but no library (- LXXX) or library path (- lyyy) is specified, which will lead to this error. The order of connecting library parameters is not right. By default, the more basic the library is, the more it should be written later, Whether it is static or dynamic, the version of GCC / LD does not match the compatibility of the version of GCC / LD. Due to the compatibility problems of the large versions of GCC 2 to GCC 3 (in fact, there are some problems in GCC 3.2 to 3.4), when using the low version of the machine on the high version machine, such errors will be caused. This problem is more common in the 32-bit environment, In addition, the 64 bit library is used carelessly in the 32-bit environment, or vice versa. The C / C + + interdependence and the mixed use of linking GCC and G + + compilation results need to ensure that both sides of extern “C” can use the interface. In our 64 bit environment, the GCC linking G + + library also needs to add – lstdc + +, For details, please refer to the description of hybrid compilation in the previous article. The problem of runtime error is basically due to the program using dlopen mode to load. So, but. So does not link all the required libraries. Please refer to the description of hybrid use of static library and dynamic library in the above section

     

Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string.

The following error was reported for the VUE project

Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at Object.join (path.js:375:7)
    at getSassOptions (D:\VueProj\test\node_modules\sass-loader\dist\utils.js:160:37)
    at Object.loader (D:\VueProj\test\node_modules\sass-loader\dist\index.js:36:49)

sass-loader version is too high cause, reinstall the lower version of sass-loader.

npm uninstall sass-loader
npm install --save-dev [email protected]

Compile QT source code error causes and Solutions

Qt source code compilation error:
1. Source code path contains Chinese font
2. No such file or directory can be found at compile time.
Solution:
1. Change to English path
2. When compiling the source code, add QT += widgets at the bottom of the project file. Pro.

Baidu Answer Question 2:
Write in the pro qt + = widgets QtWidget this module, introduced said, qmake will help you to generate a makefile, set up the include path and lib path, when the link set libs.
include

QApplication> Only the declaration is introduced, but there is no lib, so the link will fail.

Eclipse package explorer related problems and Solutions

Problems and Solutions:
Use case description: Right click on a project in the Package Explorer, select “Open in New Window”, close the previous Eclipse window, and close the new one
Problem: After opening Eclipse, the Package Explorer will always be in the project of open in new Window
Solutions: This solution personal feel very feasible, but may have a better way, my way is, direct delete/eclipse working directory workspace \. Metadata \. Plugins \ org. The eclipse UI. The workbench folder workbench. The XML file, then, the eclipse before some of the relevant Settings window will disappear, but this does not trouble, and this method can make the eclipse open load something small and open eclipse will fairly quickly
The
Problem and Solution ii:
Use case description: As mentioned in question 1 above, the project that opened in the new window was either deleted in Explorer or changed its name
Problem: The Package Explorer will always be empty
Solution: can be as a method to solve above problem, but there is a better, open the workbench. XML, find the input factoryID = “org. Eclipse. UI. Internal. Model. ResourceFactory”, change can be put behind the path values, the said the root directory “/”

TFTP: server says: file not found solution

Under Linux, regardless of which super-Server, inetd, or xinetd is used, the TFTP service is disabled by default, so modify the file to open the service.
According to the installation method of (1), the file /etc/xinetd.d/ TFTP can be modified. It is mainly to set the root directory of the TFTP server and start the service. The modified file is as follows:
service tftp
{socket_type = dgram
Protocol = udp
Wait = yes
User = root
Server =/usr/sbin/in TFTPD
Server_args = -s/home/LQM/tftpboot – c
Disable = no
Per_source = 11
The CPS = 100 2
Flags = IPv4
}
Server_args = -s < server_args= -s < path> -c, where < path> Change to the root directory of your TFTP-server. The parameter -s specifies chroot and -c specifies that files can be created.
3. Create TFTP root directory and start TFTP-Server.
#mkdir /home/lqm/tftpboot
# chmod o + w/home/LQM/tftpboot
#service xinetd restart
Stop xinetd: [sure]
start xinetd: [sure]
At this point, TFTP-Server is started. You can log in to test the following commands:
# TFTP & lt; your-ip-address>
tftp> get < download file>
tftp> put < upload file>
tftp> q
#

installation process problems and causes
phenomenon 1:
tftp> Log
Transfer timed out.
reason:
TFTPD service doesn’t start
Phenomenon.
tftp> put test2
Error code 0: Permission denied

run the command, check the system log
# tail /var/log/messages
found the following text:
Mar 24 19:05:26 localhost set: SELinux is preventing /usr/sbin/in. TFTPD (tftpd_t) \”write\” to tftpboot (tftpdir_t). For complete SELinux messages.run sealert-l 40a5a6bf-8ded-4bfa-ab6e-fa669a25fc6c
know this is caused by SELinux, in FC3 and FC versions after FC3 SELinux is turned on by default, now close it, modify the file /etc/sysconfig/ SELinux, set which
SELINUX=disabled
Then restart the computer
Or execute the system-config-SecurityLevel command to open the Security-Level Configuration dialog box and change “forced” to “allowed” in the SELinux (S) option.
Phenomenon 3:
tftp> Log
Error code 1: File not found
reason:
specified File does not exist; Or the -c option is not specified in the TFTPD boot parameter, allowing the file to be uploaded
Phenomenon 4:
tftp> Get test.log
Error code 2: Only absolute filenames allowed
reason:
server_args set in /etc/xinetd.d/ tftpd-hpa
cat /etc/defaul/tftpd-hpa
#Defaults for tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON=\”no\”
OPTIONS=\”-s /home/tftpd-c-p-u 077-u To set TFTPD \”
, simply change server_args = to your server folder

Solution of Oracle error 6550

When exporting data using the EXP command, the following appears:
EXP-00056: ORACLE error 6550 encountered
ORA-06550: line 1, column 41:
PLS-00302: component ‘SET_NO_OUTLINES’ must be declared
ORA-06550: line 1, column 15:
PL/SQL: Statement ignored
EXP-00000: Export terminated unsuccessfully
Cause
Use of Higher Version Export utility (10.2.0.1) on Lower Version database(9.2.0.6).
The main reason is that the server and client versions are not correct
You can modify oracle’s in the environment variable (Path)
D:/oracle/product/10.2.0/db_1/bin; D:/oracle/product/10.2.0/client_1/bin; The location of the
 

MySQL startup problem (ERROR 1045 (28000): Access denied for user’ODBC’@’localhost’ (using password: NO))

2011-03-18 wcdj
 
The solution is as follows:
(1) open mysql service because I installed the selected manual boot at that time.
(2) add the bin directory of mysql installation to the system PATH environment variable, using; (semicolon) partition.
(3) then open CMD and type the command: mysql-u username -p password. Enter mysql-u root-p my root password on my machine, and you will be able to enter mysql.
 
As shown in the figure below:

 
Reset password:
$mysql -u root -p
login password # mysql server mysql> Use mysql # using mysql database
mysql> Update user set password= password (“123456”) where user =’root’ # update user password
mysql> Flush privileges # to refresh the permissions
mysql> Quit # Quit the mysql server